Url

Url

new Url(options)

Defines a URL.

Parameters:
Name Type Description
options Object | String
Source:

Extends

Members

auth :Object

Type:
  • Object
Source:

hash :String

Type:
  • String
Source:

host :Array.<String>

Type:
  • Array.<String>
Source:

path :Array.<String>

Type:
  • Array.<String>
Source:

port :String

Type:
  • String
Source:

protocol :String

Type:
  • String
Source:

query :PropertyList.<QueryParam>

Type:
Source:
To Do:
  • consider setting this as undefined in v4 otherwise it's difficult to detect URL like `localhost/?`. currently it's replying upon a single member with empty key.

variables :VariableList

Type:
Source:

Methods

(static) isUrl(obj) → {Boolean}

Checks whether an object is a Url

Parameters:
Name Type Description
obj *
Source:
Returns:
Type
Boolean

(static) parse(url) → {Object}

Parses a string to a PostmanUrl, decomposing the URL into it's constituent parts, such as path, host, port, etc.

Parameters:
Name Type Description
url String
Source:
Returns:
Type
Object

addQueryParams(params)

Add query parameters to the URL.

Parameters:
Name Type Description
params Object | String

Key value pairs to add to the URL.

Source:

findInParents(property, customizeropt) → {*|undefined}

Tries to find the given property locally, and then proceeds to lookup in each parent, going up the chain as necessary. Lookup will continue until customizer returns a truthy value. If used without a customizer, the lookup will stop at the first parent that contains the property.

Parameters:
Name Type Attributes Description
property String
customizer function <optional>
Inherited From:
Source:
Returns:
Type
* | undefined

forEachParent(options, iterator)

Invokes the given iterator for every parent in the parent chain of the given element.

Parameters:
Name Type Description
options Object

A set of options for the parent chain traversal.

Properties
Name Type Attributes Default Description
withRoot Boolean <optional>
<nullable>
false

Set to true to include the collection object as well.

iterator function

The function to call for every parent in the ancestry chain.

Inherited From:
Source:
To Do:
  • Cache the results

getHost() → {String}

Returns the host part of the URL

Source:
Returns:
Type
String

getPath(unresolvedopt, nullable) → {String}

Returns the request path, with a leading '/'.

Parameters:
Name Type Attributes Default Description
unresolved Boolean <optional>
<nullable>
false
Source:
Returns:
Type
String

getPathWithQuery() → {*|String}

Returns the complete path, including the query string.

Source:
Returns:
Type
* | String
Example
/something/postman?hi=notbye

getQueryString() → {String}

Returns the stringified query string for this URL.

Source:
Returns:
Type
String

getRemote(forcePortopt, nullable) → {String}

Returns the host and port (if any), separated by a ":"

Parameters:
Name Type Attributes Default Description
forcePort Boolean <optional>
<nullable>
false

forces the port to be added even for the protocol default ones (89, 443)

Source:
Returns:
Type
String

meta() → {*}

Returns the meta keys associated with the property

Inherited From:
Source:
Returns:
Type
*

parent() → {*|undefined}

Returns the parent of item

Inherited From:
Source:
Returns:
Type
* | undefined

removeQueryParams(params)

Removes query parameters from the URL.

Parameters:
Name Type Description
params Array.<QueryParam> | Array.<String> | String

Params should be an array of strings, or an array of actual query parameters, or a string containing the parameter key.

Source:

toJSON()

Returns the JSON representation of a property, which conforms to the way it is defined in a collection. You can use this method to get the instantaneous representation of any property, including a Collection.

Inherited From:
Source:

toString(forceProtocolopt) → {String}

Unparses a {PostmanUrl} into a string.

Parameters:
Name Type Attributes Description
forceProtocol Boolean <optional>

Forces the URL to have a protocol

Source:
Returns:
Type
String

update(url)

Set a URL.

Parameters:
Name Type Description
url String | Object
Source: