uri-js
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
punycode | 2.3.1 | 7.42 kB | MIT | prod |
URI.js is a JavaScript library that provides parsing, validating and resolving functionality for URIs (Uniform Resource Identifiers) and IRIs (International Resource Identifiers). Fully compliant with multiple RFC (Request for Comments) standards, the library is extendable, allowing custom scheme-dependent processing rules. It also has features for comparing and normalizing URIs, supporting both IPv4 and IPv6 and is designed with versatility for usage in any JavaScript environment, including browsers and Node.js.
URI.js is available as an npm package and can be installed via npm or yarn. Here's an example of the installation command:
npm install uri-js
# OR
yarn add uri-js
Then, in your JavaScript file, you can require it as follows:
const URI = require("uri-js");
Alternatively, if you're using ES6+ syntax (ESNEXT) or TypeScript, you can import it this way:
import * as URI from "uri-js";
Using URI.js involves invoking its methods such as parse()
, serialize()
, normalize()
, resolve()
, and others on your URIs. Here are some usage examples:
//Parse a URI
let parsed = URI.parse("uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body");
//Serialize a URI
let serialized = URI.serialize({scheme : "http", host : "example.com", fragment : "footer"});
//Normalize a URI
let normalized = URI.normalize("HTTP://ABC.com:80/%7Esmith/home.html");
//Resolve a URI
let resolved = URI.resolve("uri://a/b/c/d?q", "../../g");
The detailed documentation and API references for URI.js are located directly in the README of the GitHub repository. The documentation provides a thorough explanation of each method available in the library and demonstrates how to use the library with specific use case examples. The GitHub repository can be accessed through the link: git+ssh://git@github.com/garycourt/uri-js.git.