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

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

\n", "modules": [ { "textRaw": "URL Parsing", "name": "url_parsing", "desc": "

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", "modules": [ { "textRaw": "Escaped Characters", "name": "escaped_characters", "desc": "

Spaces (' ') and the following characters will be automatically escaped in the\nproperties of URL objects:\n\n

\n
< > " ` \\r \\n \\t { } | \\ ^ '
\n
\n

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

\n", "type": "module", "displayName": "Escaped Characters" } ], "type": "module", "displayName": "URL Parsing" } ], "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. If false then the query property will not be parsed or\ndecoded. 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" } ] }