Package Exports
- uri-js-replace
- uri-js-replace/dist/index.js
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 (uri-js-replace) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
URI parsing/validating/resolving library
Replacement for abandoned library uri-js aka "URI.js"
- Based on Node.js/browser URL.
- Without using of deprecated punycode api.
- Works in Node and browser
Add to your package.json
{
"overrides": {
"uri-js": "npm:uri-js-replace"
}
}and run
npm updateOr install from scratch
npm i uri-js-replaceimport * as URI from "uri-js";Usage examples
Parsing
URI.parse("uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body");
//returns:
//{
// scheme : "uri",
// userinfo : "user:pass",
// host : "example.com",
// port : 123,
// path : "/one/two.three",
// query : "q1=a1&q2=a2",
// fragment : "body"
//}###Serializing
URI.serialize({scheme : "http", host : "example.com", fragment : "footer"}) === "http://example.com/#footer"Resolving
URI.resolve("uri://a/b/c/d?q", "../../g") === "uri://a/g"Normalizing
URI.normalize("HTTP://ABC.com:80/%7Esmith/home.html") === "http://abc.com/~smith/home.html"Comparison
URI.equal("example://a/b/c/%7Bfoo%7D", "eXAMPLE://a/./b/../b/%63/%7bfoo%7d") === trueTests
All tests copied from original repository
vitest