Socket
Socket
Sign inDemoInstall

@jridgewell/resolve-uri

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @jridgewell/resolve-uri

Resolve a URI relative to an optional base URI


Version published
Weekly downloads
41M
decreased by-1.06%
Maintainers
1
Install size
51.9 kB
Created
Weekly downloads
 

Package description

What is @jridgewell/resolve-uri?

The @jridgewell/resolve-uri package is designed to resolve URIs in a consistent and reliable manner. It provides functionality for resolving relative URIs against a base URI, similar to how web browsers resolve relative links. This can be particularly useful in web development and applications that need to handle various URI manipulations.

What are @jridgewell/resolve-uri's main functionalities?

Resolving relative URIs

This feature allows the resolution of a relative URI against a base URI, effectively calculating the absolute URI. It's particularly useful for web applications that need to dynamically resolve links or resources.

"const resolveUri = require('@jridgewell/resolve-uri');\nconst baseUri = 'http://example.com/dir/page.html';\nconst relativeUri = '../image.png';\nconst resolvedUri = resolveUri(relativeUri, baseUri);\nconsole.log(resolvedUri); // Outputs: 'http://example.com/image.png'"

Other packages similar to @jridgewell/resolve-uri

Readme

Source

@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'
InputBaseResolutionExplanation
https://example.comanyhttps://example.com/Input is normalized only
//example.comhttps://base.com/https://example.com/Input inherits the base's protocol
//example.comrest//example.com/Input is normalized only
/examplehttps://base.com/https://base.com/exampleInput inherits the base's origin
/example//base.com///base.com/exampleInput inherits the base's host and remains protocol relative
/examplerest/exampleInput is normalized only
examplehttps://base.com/dir/https://base.com/dir/exampleInput is joined with the base
examplehttps://base.com/filehttps://base.com/exampleInput is joined with the base without its file
example//base.com/dir///base.com/dir/exampleInput is joined with the base's last directory
example//base.com/file//base.com/exampleInput is joined with the base without its file
example/base/dir//base/dir/exampleInput is joined with the base's last directory
example/base/file/base/exampleInput is joined with the base without its file
examplebase/dir/base/dir/exampleInput is joined with the base's last directory
examplebase/filebase/exampleInput is joined with the base without its file

Keywords

FAQs

Last updated on 14 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc