Skip to content

uri.js

6,258 2 104 MIT
0.1.3 (28 Jun 2022) Jun 18 2013 482 (month)

URI.js is a lightweight JavaScript library for working with URLs and URIs in Node.js and the browser. It provides a simple and consistent interface for parsing, manipulating, and building URLs and URIs.

Example Use


const URI = require('uri-js');

// parse url for values
const parsedUrl = URI.parse("https://www.example.com/search?q=query+string#fragment");
console.log(parsedUrl);
/* Output:
{
    scheme: 'https',
    authority: 'www.example.com',
    path: '/search',
    query: 'q=query+string',
    fragment: 'fragment'
}
*/

// create url from values
const urlComponents = {
    scheme: 'https',
    authority: 'www.example.com',
    path: '/search',
    query: 'q=query+string',
    fragment: 'fragment'
};
const url = URI.serialize(urlComponents);
console.log(url);
// Output: 'https://www.example.com/search?q=query+string#fragment'

Alternatives / Similar


526 9.0.5 (1 year, 3 months ago) May 05 2015 compare
ip
1,520 2.0.1 (10 months ago) Aug 15 2012 compare
6,791 9.1.1 (2 months ago) Nov 13 2013 compare

Other Languages

1,217 0.6.4 (2 months ago) Dec 28 2012 compare
1,349 1.2.1 (6 months ago) Feb 14 2011 compare
url
103 v2.1.3 (2 months ago) Apr 15 2018 compare
Was this page helpful?