mazey
    Preparing search index...

    Function getURLPathExtension

    • Extract the extension from a URL or path after removing query and fragment text.

      This string-based helper does not inspect file contents or detect MIME types. It retains everything after the first dot in the final slash-delimited segment, so archive.tar.gz returns tar.gz. It does not parse URL authority: an origin-only input such as https://example.com returns com.

      Usage:

      import { getURLPathExtension } from "mazey";

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

      Output:

      png jpg jpeg jpeg ""
      

      Parameters

      • url: string

        The URL or path to inspect.

      Returns string | boolean

      The extension without the leading dot, or an empty string when absent.