source: trip-planner-front/node_modules/url/README.md

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.5 KB
Line 
1# node-url
2
3[![Build Status](https://travis-ci.org/defunctzombie/node-url.svg?branch=master)](https://travis-ci.org/defunctzombie/node-url)
4
5This module has utilities for URL resolution and parsing meant to have feature parity with node.js core [url](http://nodejs.org/api/url.html) module.
6
7```js
8var url = require('url');
9```
10
11## api
12
13Parsed URL objects have some or all of the following fields, depending on
14whether or not they exist in the URL string. Any parts that are not in the URL
15string will not be in the parsed object. Examples are shown for the URL
16
17`'http://user:pass@host.com:8080/p/a/t/h?query=string#hash'`
18
19* `href`: The full URL that was originally parsed. Both the protocol and host are lowercased.
20
21 Example: `'http://user:pass@host.com:8080/p/a/t/h?query=string#hash'`
22
23* `protocol`: The request protocol, lowercased.
24
25 Example: `'http:'`
26
27* `host`: The full lowercased host portion of the URL, including port
28 information.
29
30 Example: `'host.com:8080'`
31
32* `auth`: The authentication information portion of a URL.
33
34 Example: `'user:pass'`
35
36* `hostname`: Just the lowercased hostname portion of the host.
37
38 Example: `'host.com'`
39
40* `port`: The port number portion of the host.
41
42 Example: `'8080'`
43
44* `pathname`: The path section of the URL, that comes after the host and
45 before the query, including the initial slash if present.
46
47 Example: `'/p/a/t/h'`
48
49* `search`: The 'query string' portion of the URL, including the leading
50 question mark.
51
52 Example: `'?query=string'`
53
54* `path`: Concatenation of `pathname` and `search`.
55
56 Example: `'/p/a/t/h?query=string'`
57
58* `query`: Either the 'params' portion of the query string, or a
59 querystring-parsed object.
60
61 Example: `'query=string'` or `{'query':'string'}`
62
63* `hash`: The 'fragment' portion of the URL including the pound-sign.
64
65 Example: `'#hash'`
66
67The following methods are provided by the URL module:
68
69### url.parse(urlStr, [parseQueryString], [slashesDenoteHost])
70
71Take a URL string, and return an object.
72
73Pass `true` as the second argument to also parse
74the query string using the `querystring` module.
75Defaults to `false`.
76
77Pass `true` as the third argument to treat `//foo/bar` as
78`{ host: 'foo', pathname: '/bar' }` rather than
79`{ pathname: '//foo/bar' }`. Defaults to `false`.
80
81### url.format(urlObj)
82
83Take a parsed URL object, and return a formatted URL string.
84
85* `href` will be ignored.
86* `protocol` is treated the same with or without the trailing `:` (colon).
87 * The protocols `http`, `https`, `ftp`, `gopher`, `file` will be
88 postfixed with `://` (colon-slash-slash).
89 * All other protocols `mailto`, `xmpp`, `aim`, `sftp`, `foo`, etc will
90 be postfixed with `:` (colon)
91* `auth` will be used if present.
92* `hostname` will only be used if `host` is absent.
93* `port` will only be used if `host` is absent.
94* `host` will be used in place of `hostname` and `port`
95* `pathname` is treated the same with or without the leading `/` (slash)
96* `search` will be used in place of `query`
97* `query` (object; see `querystring`) will only be used if `search` is absent.
98* `search` is treated the same with or without the leading `?` (question mark)
99* `hash` is treated the same with or without the leading `#` (pound sign, anchor)
100
101### url.resolve(from, to)
102
103Take a base URL, and a href URL, and resolve them as a browser would for
104an anchor tag. Examples:
105
106 url.resolve('/one/two/three', 'four') // '/one/two/four'
107 url.resolve('http://example.com/', '/one') // 'http://example.com/one'
108 url.resolve('http://example.com/one', '/two') // 'http://example.com/two'
Note: See TracBrowser for help on using the repository browser.