Provides with an Url parser that deconstructs an url into a managable object and back to a string.
url = require('urlparser');
var u = url.parse('http://user:[email protected]/login?x=42');
u.host.hostname = 'database.kaerus.com'
u.host.password = 'secret';
u.host.port = 8529;
u.query.parts.push('a=13');
u.toString(); // 'http://user:[email protected]:8529/login?x=42&a=13'
@class UrlParser
Host attributes
host: {
protocol: {String}
username: {String}
password: {String}
hostname: {String}
port: {String}
}
Path information
path: {
base: {String} // base path without hash
name: {String} // file or directory name
hash: {String} // the #hash part in path
}
Query parameters
query: {
parts: {Array} // query segments ['a=3','x=2']
params: {Object} // query parameters {a:3,x:2}
}