XOS URL Parser
Introduction
Parses a URL and the contained query string into an object
- source
- protocol
- authority
- credentials
- username
- password
- host
- port
- relative
- path
- directory
- file
- query_string
- query (object)
- anchor
Installation
npm install xos.url
Usage
Simply require and instantiate a URL
URL=url='https://user:password@sub.domain.com:1337/path/to/folder/file.extension?para=value¶2=value2&user[name]=myusername&user[password]=mypassword&another[nested][object][key]=nestedobjectvalue#anchor&anchorpart'u=urlconsole
output
Output of the above snippet is:
source: 'https://user:password@sub.domain.com:1337/path/to/folder/file.extension?para=value¶2=value2&user[name]=myusername&user[password]=mypassword&another[nested][object][key]=nestedobjectvalue#anchor&anchorpart' protocol: 'https' authority: 'user:password@sub.domain.com:1337' credentials: 'user:password' username: 'user' password: 'password' host: 'sub.domain.com' port: '1337' relative: '/path/to/folder/file.extension?para=value¶2=value2&user[name]=myusername&user[password]=mypassword&another[nested][object][key]=nestedobjectvalue#anchor&anchorpart' path: '/path/to/folder/file.extension' directory: '/path/to/folder/' file: 'file.extension' query_string: 'para=value¶2=value2&user[name]=myusername&user[password]=mypassword&another[nested][object][key]=nestedobjectvalue' anchor: 'anchor&anchorpart' query: para: 'value' para2: 'value2' user: name: 'myusername' password: 'mypassword' another: nested: Object