postman-url-encoder/parser

This module helps to break URL strings up into components (protocol, auth, host, port, path, query, and hash) keeping the variables intact.

Source:
Example
const parser = require('postman-url-encoder/parser')

// returns
// {
//   raw: 'protocol://{{user}}:{{p@ssw?rd}}@{{host.name}}.com:{{#port}}/p/a/t/h?q=query#hash',
//   protocol: 'protocol',
//   auth: [ '{{user}}', '{{p@ssw?rd}}' ],
//   host: [ '{{host.name}}', 'com' ],
//   port: '{{#port}}',
//   path: [ 'p', 'a', 't', 'h' ],
//   query: [ 'q=query' ],
//   hash: 'hash'
// }
parser.parse('protocol://{{user}}:{{p@ssw?rd}}@{{host.name}}.com:{{#port}}/p/a/t/h?q=query#hash')

Methods

(inner) parse(urlString) → {Object}

Parses the input string by decomposing the URL into constituent parts, such as path, host, port, etc.

Parameters:
Name Type Description
urlString String

The URL string to parse

Source:
Returns:

Parsed URL object

Type
Object