Skip to content

iexitdev/url-paths

url-paths

Path normalization helpers for build tools that turn file paths into URL paths.

urix is deprecated and its original API depended on the current operating system. This package keeps the migration-friendly urix(path) function, adds deterministic options for tests and cross-platform tooling, and exposes small helpers for explicit path normalization.

Install

npm install url-paths

Usage

import { toUrlPath, urix } from "url-paths";

urix("c:\\users\\you\\foo", { platform: "win32" });
// "/users/you/foo"

toUrlPath("\\server\\share\\asset.png", { platform: "win32" });
// "//server/share/asset.png"

API

urix(path, options?)

Migration-compatible alias for toUrlPath(path, options).

toUrlPath(path, options?)

Converts Windows-style paths to URL-friendly slash-separated paths when platform is "win32". On POSIX platforms it preserves the old no-op behavior unless force is set.

Options:

  • platform: platform to emulate. Defaults to process.platform.
  • force: normalize slashes even on non-Windows platforms.
  • preserveDrive: keep C: instead of converting C:\x to /x.

normalizeSlashes(path)

Replaces backslashes with slashes.

stripWindowsDrive(path)

Converts leading Windows drive paths such as C:/users to /users.

Migration Position

url-paths is an independent alternative or migration helper for projects moving away from urix. It is not affiliated with the original package maintainers or project.

For release context, see the local migration guide, examples, compatibility notes, source metadata, and adoption plan.

About

Deterministic path-to-URL normalization helpers and urix-compatible API.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors