JSPM

url-resolve-browser

1.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1233
  • Score
    100M100P100Q104802F
  • License MIT

resolve urls in the browser like url.resolve in node.js.

Package Exports

  • url-resolve-browser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (url-resolve-browser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

url-resolve-browser

This module resolves URLs like node.js's url.resolve but works in the browser. Other modules exist to fulfill this purpose but they do so by creating html elements, adding them to the page, then removing them. This module is purely JavaScript.

Install:

npm i url-resolve-browser --save

Usage:

const urlResolve = require('url-resolve-browser');
urlResolve(base, relative);

Where base is a net path (http://example.com) with the optional pieces of query (?query=query&two=....) and/or hash (#location) and relative is a either a net path, absolute path (/absolute/path) or a relative path (relative/path) and can also contain the query and/or hash like before.

Details:

This module is NOT the same as node.js' url.resolve as it requires the first argument to be a net path. Also, This module does not do any URL encoding (E.G. { => %7B).

The logic for this module was primarily derived from the following document: Link

Running tests

  1. Clone the repo.
  2. Change to directory
  3. npm i
  4. npm test

Contributing:

Contributions are welcome, either extending functionality or fixing issues. In order to contribute please make an issue detailing what you would like to change so we can discuss it then a PR can be made either by the reported or someone else (whomever would like to).