Skip to main content

Utilities for working with file system paths

This package works with Cloudflare Workers, Deno, Browsers
This package works with Cloudflare Workers
This package works with Deno
This package works with Browsers
JSR Score
94%
Published
3 weeks ago (1.0.8)

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 "@std/path/posix/from-file-url";
import { assertEquals } from "@std/assert";

assertEquals(fromFileUrl("file:///home/foo"), "/home/foo");

Or, for Windows:

import { fromFileUrl } from "@std/path/windows/from-file-url";
import { assertEquals } from "@std/assert";

assertEquals(fromFileUrl("file:///home/foo"), "\\home\\foo");

Functions for working with URLs can be found in @std/path/posix.

Add Package

deno add jsr:@std/path

Import symbol

import * as path from "@std/path";

---- OR ----

Import directly with a jsr specifier

import * as path from "jsr:@std/path";