URL

This module has utilities for URL resolution and parsing. Call require('url') to use it.

Parsed URL objects have some or all of the following fields, depending on whether or not they exist in the URL string. Any parts that are not in the URL string will not be in the parsed object. Examples are shown for the URL

'pass@host.com:8080/p/a/t/h?query=string#hash'>http://user:pass@host.com:8080/p/a/t/h?query=string#hash'

The following methods are provided by the URL module:

Table of Contents #

url.parse(urlStr, parseQueryString=false, slashesDenoteHost=false) #

Take a URL string, and return an object.

Pass true as the second argument to also parse the query string using the querystring module.

Pass true as the third argument to treat //foo/bar as { host: 'foo', pathname: '/bar' } rather than { pathname: '//foo/bar' }.

url.format(urlObj) #

Take a parsed URL object, and return a formatted URL string.

url.resolve(from, to) #

Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag.


Documentation generated by mdoc.