{ "source": "doc/api/url.markdown", "modules": [ { "textRaw": "URL", "name": "url", "stability": 3, "stabilityText": "Stable", "desc": "

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

\n

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

\n

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

\n\n

The following methods are provided by the URL module:\n\n

\n", "methods": [ { "textRaw": "url.parse(urlStr[, parseQueryString][, slashesDenoteHost])", "type": "method", "name": "parse", "desc": "

Take a URL string, and return an object.\n\n

\n

Pass true as the second argument to also parse the query string using the\nquerystring module. If true then the query property will always be\nassigned an object, and the search property will always be a (possibly\nempty) string. Defaults to false.\n\n

\n

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

\n", "signatures": [ { "params": [ { "name": "urlStr" }, { "name": "parseQueryString", "optional": true }, { "name": "slashesDenoteHost", "optional": true } ] } ] }, { "textRaw": "url.format(urlObj)", "type": "method", "name": "format", "desc": "

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

\n

Here's how the formatting process works:\n\n

\n\n", "signatures": [ { "params": [ { "name": "urlObj" } ] } ] }, { "textRaw": "url.resolve(from, to)", "type": "method", "name": "resolve", "desc": "

Take a base URL, and a href URL, and resolve them as a browser would for\nan anchor tag. Examples:\n\n

\n
url.resolve('/one/two/three', 'four')         // '/one/two/four'\nurl.resolve('http://example.com/', '/one')    // 'http://example.com/one'\nurl.resolve('http://example.com/one', '/two') // 'http://example.com/two'
\n", "signatures": [ { "params": [ { "name": "from" }, { "name": "to" } ] } ] } ], "type": "module", "displayName": "URL" } ] }