@stackline/resolve-uri
v1.0.2
Published
Resolve a URI relative to an optional base URI
Maintainers
Readme
@stackline/resolve-uri
Resolve a URI relative to an optional base URI.
Documentation | npm | Issues | Repository
Current package version: 1.0.2
Why this package?
@stackline/resolve-uri is the Stackline-maintained distribution of @jridgewell/[email protected]. It is an independent continuation of @jridgewell/resolve-uri; original authors and licenses remain credited below.
Compatibility
| Item | Value |
| :--- | :--- |
| Package | @stackline/[email protected] |
| API target | @jridgewell/[email protected] |
| 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-uriPreserve existing imports and plugin resolution with an npm alias:
npm install @jridgewell/resolve-uri@npm:@stackline/resolve-uriUsage 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-uriUsage
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 project: @jridgewell/resolve-uri.
- Justin Ridgewell.
- Copyright 2019 Justin Ridgewell [email protected].
- Stackline maintenance: Alexandro Paixao Marques and Stackline contributors.
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.
