Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
docs: explain how url.format works (search trumps query, etc)
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ ONeal authored and bnoordhuis committed Sep 3, 2011
1 parent 3bf20e4 commit 087d210
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/api/url.markdown
Expand Up @@ -57,6 +57,20 @@ Pass `true` as the third argument to treat `//foo/bar` as

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

* `href` will be ignored.
* `protocol`is treated the same with or without the trailing `:` (colon).
* The protocols `http`, `https`, `ftp`, `gopher`, `file` will be postfixed with `://` (colon-slash-slash).
* All other protocols `mailto`, `xmpp`, `aim`, `sftp`, `foo`, etc will be postfixed with `:` (colon)
* `auth` will only be used if `host` is absent.
* `hostname` will only be used if `host` is absent.
* `port` will only be used if `host` is absent.
* `host` will be used in place of `auth`, `hostname`, and `port`
* `pathname` is treated the same with or without the leading `/` (slash)
* `search` will be used in place of `query`
* `query` (object; see `querystring`) will only be used if `search` is absent.
* `search` is treated the same with or without the leading `?` (question mark)
* `hash` is treated the same with or without the leading `#` (pound sign, anchor)

### url.resolve(from, to)

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

0 comments on commit 087d210

Please sign in to comment.