Skip to content

iexitdev/url-resolve-modern

url-resolve-modern

Sequential URL resolution for JavaScript and TypeScript.

resolve-url is deprecated and used browser anchor elements to resolve URLs. This package keeps the same left-to-right resolution model, uses the standard URL API, and adds an explicit Node-friendly base helper.

Install

npm install url-resolve-modern

Usage

import { resolveUrl, resolveUrlFrom } from "url-resolve-modern";

resolveUrl("https://example.com/articles/resolving-urls/edit", "remove");
// "https://example.com/articles/resolving-urls/remove"

resolveUrlFrom(
  "https://example.com/static/scripts/app.js",
  "../source-maps/app.js.map",
  "../coffee/app.coffee"
);
// "https://example.com/static/coffee/app.coffee"

In browsers, resolveUrl("relative/path") uses window.location.href as the starting base. In Node, provide an absolute first URL or use resolveUrlFrom(base, ...urls).

API

resolveUrl(...urls)

Resolves URLs left to right. The first URL must be absolute unless a browser window.location base exists.

resolveUrlFrom(base, ...urls)

Resolves URLs left to right from an explicit base.

isAbsoluteUrl(value)

Returns whether a value can be parsed as an absolute URL.

UrlResolveError

Thrown when resolution needs a base but none is available.

Migration Position

url-resolve-modern is an independent alternative or migration helper for projects moving away from resolve-url. 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

Sequential URL resolution using the standard URL API with resolve-url migration helpers.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors