Open URL JS 🔍
Simply manage urls.
Install
npm install open-url-js
Usage
var Url = ; var url = 'https://www.myapp.com:3000/users/:id/#profile?user[lang]=fr';url;// => Url {// protocol: 'https',// host: 'www.myapp.com',// port: 3000,// path: Pathname ['users', ':id', root: true],// hash: 'profile',// parameters: Parameters {// user: Parameters {// lang: fr// }// }// } urlpathid = 4;urlstring;// => 'https://www.myapp.com:3000/users/4/#profile?user[lang]=fr'; urlparameters = lang: 'en' zone: 'United States';urlstring;// => 'https://www.myapp.com:3000/users/4/#profile?lang=fr&zone=United%20States';
Url
Kind: global class
- Url
- new Url(...string)
- .string :
string
- .protocol :
string
- .host :
string
- .port :
string
- .hash :
string
- .path :
Pathname
- .parameters :
Parameters
- .clear() ⇒
Url
- .toString() ⇒
string
new Url(...string)
Create a Url object.
Param | Type | Description |
---|---|---|
...string | Object |
Same value as string. |
string
url.string : A string corresponding to the url. When set, it will be parsed.
Kind: instance property of Url
string
url.protocol : The protocol of the url.
Kind: instance property of Url
string
url.host : The host of the url.
Kind: instance property of Url
string
url.port : The port of the url.
Kind: instance property of Url
string
url.hash : The hash of the url.
Kind: instance property of Url
Pathname
url.path : The path of the url.
Kind: instance property of Url
Parameters
url.parameters : The parameters of the url.
Kind: instance property of Url
Url
url.clear() ⇒ Clears the url.
Kind: instance method of Url
Returns: Url
- Itself.
string
url.toString() ⇒ Kind: instance method of Url
Returns: string
- Value of string.