getPath()function

getPath(inputPath: Nullish<PossiblePath>, inputBase: AbsolutePath = "/"): AbsolutePath | undefined
ParamType
inputPathNullish<PossiblePath>
Absolute path e.g. /a/b/c, relative path e.g. ./a or b or ../c, URL string e.g. http://shax.com/a/b/c, or URL instance. required
inputBaseAbsolutePath
Absolute path used for resolving relative paths in inputPath. Defaults to "/"
Return
AbsolutePath | undefined
Absolute path with a leading slash but no trailing slash, e.g. /a/c/b, or undefined if inputPath is not a valid path.

Resolve a relative or absolute path and return the absolute path, or undefined if not a valid path.

  • Normalises runs of // more than one slash.
  • Normalises \ windows paths.
  • Strips trailing slashes.

Examples

getPath("./a", "/b") // "/b/a"