augment-vir - v31.40.0
    Preparing search index...

    Function extractExtension

    • Extracts a path's extension, amongst other things, from the given path, without relying on Node.js built-in packages (this works in a browser).

      Parameters

      • path: string
      • OptionalsepOverride: "/" | "\\"

        By default, the path separator is determined by defaultSep. With this input you can override the path separator in use.

      Returns { basename: string; dirname: string; extension: string; tail: string }

      • basename: string

        The file name itself. This will only be an empty string if the given path is itself empty. This does not include the extension.

      • dirname: string

        The part of the path that is the path to the file. This will be an empty string if there is none. Includes the all trailing and leading slashes, if they exist in path.

      • extension: string

        The extension extracted from the path. This will be an empty string if there is no extension. This includes a leading dot, if an extension exists.

      • tail: string

        Any query '?' and/or hash '#' data in the given path. This will be an empty string if no query or hash data exists in the given path. Includes the leading '?' or '#'.

      import {extractExtension} from '@augment-vir/common';

      const results = extractExtension('/users/stuff/file.ts?tail');

      // results = {
      // basename: 'file',
      // dirname: '/users/stuff/',
      // extension: '.ts',
      // tail: '?tail',
      // }