Function getUrlFileType

  • EN: Get the file type of the url.

    ZH: 获取文件后缀名

    Usage:

    const ret1 = getUrlFileType('https://example.com/a/b/c.png');
    const ret2 = getUrlFileType('https://example.com/a/b/c.jpg');
    const ret3 = getUrlFileType('https://example.com/a/b/c.jpeg');
    const ret4 = getUrlFileType('/a/b/c.jpeg');
    const ret5 = getUrlFileType('https://example.com/a/b/c.v/a');
    console.log(ret1, ret2, ret3, ret4, ret5);

    Output:

    png jpg jpeg jpeg ''
    

    Parameters

    • url: string

    Returns boolean | string