Alexandro.Net

Download README · GitHub release

@stackline/resolve-uri

Resolve a URI relative to an optional base URI.

npm version license GitHub repository Docs Reddit community

Documentation | npm | Issues | Repository

Current package version: 1.0.2


Why this package?

@stackline/resolve-uri is the Stackline-maintained distribution of @jridgewell/resolve-uri@3.1.2. It is an independent continuation of @jridgewell/resolve-uri; original authors and licenses remain credited below.

Compatibility

Item Value
Package @stackline/resolve-uri@1.0.2
API target @jridgewell/resolve-uri@3.1.2
Supported Node.js >=6.0.0
License MIT
Main entry dist/resolve-uri.umd.js
Module entry dist/resolve-uri.mjs
Types dist/types/resolve-uri.d.ts
Runtime dependencies none

Installation

npm install @stackline/resolve-uri

Preserve existing imports and plugin resolution with an npm alias:

npm install @jridgewell/resolve-uri@npm:@stackline/resolve-uri

Usage and API reference

@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 @stackline/resolve-uri

Usage

function resolve(input: string, base?: string): string;
import resolve from '@stackline/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

Credits and original authors

Original copyright, license notices and contributor acknowledgements remain part of this distribution. Stackline maintenance does not replace authorship of the original work.

License

MIT. See the license and notice files in the repository.

Community and Links

Use this repository's issue tracker for reproducible bugs and feature requests. Join r/Stackline for examples, usage questions and release discussions.