Utilities for working with POSIX-formatted paths.
This module also provides some functions that help when working with URLs. See the documentation for examples.
Codes in the examples uses POSIX path but it automatically use Windows path
on Windows. Use methods under posix
or win32
object instead to handle non
platform specific path like:
import { fromFileUrl } from "@std/path/posix/from-file-url"; import { assertEquals } from "@std/assert"; assertEquals(fromFileUrl("file:///home/foo"), "/home/foo");
Return the last portion of a path
.
Trailing directory separators are ignored, and optional suffix is removed.
Determines the common path from a set of paths for POSIX systems.
Return the directory path of a path
.
Return the extension of the path
with leading period.
Generate a path from ParsedPath
object.
Converts a file URL to a path string.
Convert a glob string to a regular expression.
Verifies whether provided path is absolute.
Test whether the given string is a glob.
Join all given a sequence of paths
,then normalizes the resulting path.
Like join(), but doesn't collapse "**/.." when globstar
is true.
Normalize the path
, resolving '..'
and '.'
segments.
Note that resolving these segments does not necessarily mean that all will be eliminated.
A '..'
at the top-level will be preserved, and an empty path is canonically '.'
.
Like normalize(), but doesn't collapse "**/.." when globstar
is true.
Return a ParsedPath
object of the path
.
Return the relative path from from
to to
based on current working directory.
Resolves path segments into a path
.
Converts a path string to a file URL.
Converts a path to a namespaced path. This function returns the path as is on posix.
Options for globToRegExp
, joinGlobs
,
normalizeGlob
and expandGlob
.
The character used to separate entries in the PATH environment variable.
The character used to separate components of a file path.
A regular expression that matches one or more path separators.
Add Package
deno add jsr:@std/path
Import symbol
import * as mod from "@std/path/posix";
---- OR ----
Import directly with a jsr specifier
import * as mod from "jsr:@std/path/posix";