Package Exports
- universal-url
- universal-url/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 (universal-url) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
universal-url

WHATWG
URL
for Node & Browser.
- For Node.js versions
>= 8
and some^7
, the native implementation will be used. - For Node.js versions
< 8
and some^7
, a shim will be used. - For web browsers without a native implementation, the same shim will be used.
Installation
Node.js >= 4
is required. To install, type this at the command line:
npm install universal-url
Usage
const {URL, URLSearchParams} = require('universal-url');
const url = new URL('http://domain/');
const params = new URLSearchParams('?param=value');
Global shim:
require('universal-url').shim();
const url = new URL('http://domain/');
const params = new URLSearchParams('?param=value');
Shim
URLSearchParams
is not currently supported. Be sure to feature check that it's available before performing such operations:
const url = new URL('http://domain?param=value');
if (url.searchParams !== undefined) {
// Complete implementation
} else {
// Incomplete implementation
}
if (URLSearchParams !== undefined) {
// Complete implementation
} else {
// Incomplete implementation
}
Browserify/etc
The bundled file size of this library can be large for a web browser. If this is a problem, try using universal-url-lite in your build as an alias for this module.