Skip to content

Commit 087d210

Browse files
AJ ONealbnoordhuis
AJ ONeal
authored andcommitted
docs: explain how url.format works (search trumps query, etc)
1 parent 3bf20e4 commit 087d210

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/api/url.markdown

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ Pass `true` as the third argument to treat `//foo/bar` as
5757

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

60+
* `href` will be ignored.
61+
* `protocol`is treated the same with or without the trailing `:` (colon).
62+
* The protocols `http`, `https`, `ftp`, `gopher`, `file` will be postfixed with `://` (colon-slash-slash).
63+
* All other protocols `mailto`, `xmpp`, `aim`, `sftp`, `foo`, etc will be postfixed with `:` (colon)
64+
* `auth` will only be used if `host` is absent.
65+
* `hostname` will only be used if `host` is absent.
66+
* `port` will only be used if `host` is absent.
67+
* `host` will be used in place of `auth`, `hostname`, and `port`
68+
* `pathname` is treated the same with or without the leading `/` (slash)
69+
* `search` will be used in place of `query`
70+
* `query` (object; see `querystring`) will only be used if `search` is absent.
71+
* `search` is treated the same with or without the leading `?` (question mark)
72+
* `hash` is treated the same with or without the leading `#` (pound sign, anchor)
73+
6074
### url.resolve(from, to)
6175

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

0 commit comments

Comments
 (0)