Skip to main content
Module

std/path/mod.ts

The Deno Standard Library
Latest
import * as mod from "https://deno.land/std@0.223.0/path/mod.ts";

Utilities for working with OS-specific file paths.

Functions from this module will automatically switch to support the path style of the current OS, either windows for Microsoft Windows, or posix for every other operating system, eg. Linux, MacOS, BSD etc.

To use functions for a specific path style regardless of the current OS import the modules from the platform sub directory instead.

Example, for posix:

import { fromFileUrl } from "https://deno.land/std@0.223.0/path/posix/from_file_url.ts";
const p = fromFileUrl("file:///home/foo");
console.log(p); // "/home/foo"

or, for windows:

import { fromFileUrl } from "https://deno.land/std@0.223.0/path/windows/from_file_url.ts";
const p = fromFileUrl("file:///home/foo");
console.log(p); // "\\home\\foo"

This module is browser compatible.

Functions

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, using an optional separator, which defaults to the OS default separator.

Return the directory path of a path.

Return the extension of the path with leading period.

Generate a path from FormatInputPathObject object. It does the opposite of parse.

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. Use format to reverse the result.

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.

Resolves path to a namespace path

Interfaces

Options for globToRegExp.

A parsed path object generated by path.parse() or consumed by path.format().