@jridgewell/resolve-uri (3.1.2)

Published 2026-02-24 13:49:43 +00:00 by atheaadmin

Installation

@jridgewell:registry=
npm install @jridgewell/resolve-uri@3.1.2
"@jridgewell/resolve-uri": "3.1.2"

About this package

@jridgewell/resolve-uri

Resolve a URI relative to an optional base URI

Resolve any combination of absolute URIs, protocol-realtive URIs, absolute paths, or relative paths.

Installation

npm install @jridgewell/resolve-uri

Usage

function resolve(input: string, base?: string): string;
import resolve from '@jridgewell/resolve-uri';

resolve('foo', 'https://example.com'); // => 'https://example.com/foo'
Input Base Resolution Explanation
https://example.com any https://example.com/ Input is normalized only
//example.com https://base.com/ https://example.com/ Input inherits the base's protocol
//example.com rest //example.com/ Input is normalized only
/example https://base.com/ https://base.com/example Input inherits the base's origin
/example //base.com/ //base.com/example Input inherits the base's host and remains protocol relative
/example rest /example Input is normalized only
example https://base.com/dir/ https://base.com/dir/example Input is joined with the base
example https://base.com/file https://base.com/example Input is joined with the base without its file
example //base.com/dir/ //base.com/dir/example Input is joined with the base's last directory
example //base.com/file //base.com/example Input is joined with the base without its file
example /base/dir/ /base/dir/example Input is joined with the base's last directory
example /base/file /base/example Input is joined with the base without its file
example base/dir/ base/dir/example Input is joined with the base's last directory
example base/file base/example Input is joined with the base without its file

Dependencies

Development Dependencies

ID Version
@jridgewell/resolve-uri-latest npm:@jridgewell/resolve-uri@*
@rollup/plugin-typescript 8.3.0
@typescript-eslint/eslint-plugin 5.10.0
@typescript-eslint/parser 5.10.0
c8 7.11.0
eslint 8.7.0
eslint-config-prettier 8.3.0
mocha 9.2.0
npm-run-all 4.1.5
prettier 2.5.1
rollup 2.66.0
typescript 4.5.5

Keywords

resolve uri url path
Details
npm
2026-02-24 13:49:43 +00:00
1
Justin Ridgewell
MIT
latest
9.4 KiB
Assets (1)
Versions (1) View all
3.1.2 2026-02-24