6.2.0 • Published 6 years ago
url6 v6.2.0
URL6
A more practical URL parser for Node.js that combines new and legacy APIs.
Install
npm install url6 --saveExample
const { URL } = require("url6");
var url = new URL("https://root:123456@example.com:443/dir/filename.html?lang=en-US#id");
console.log(url);
url.protocol = "http:"; // change protocol
url.hostname = "github.com"; // change hostname
url.port = 80; // change port
url.query.author = "Ayon Lee"; // modify query object.
console.log(url);API
class URL
new URL(input?: string)url.href: stringurl.protocol: stringwith trailing:.url.slashes: booleanwhether//appears after theprotocol.url.auth: stringurl.username: stringurl.password: stringurl.host: stringurl.hostname: stringwithout trailingportnumber.url.port: numberurl.origin: stringreadonly.url.path: stringurl.pathname: stringwithout trailingsearchstring.url.search: stringurl.query: { [key: string]: string }parsed by qs module.url.hash: stringurl.toString()same asurl.href.url.toJSON()same asurl.toString().
This module is meant to bring some features from Node.js 8.0+ to Node.js 6.X
or even lower versions, it cannot be run in browser, use native URL instead.