Skip to content

Commit

Permalink
doc: url.format() parameter may be a string
Browse files Browse the repository at this point in the history
PR-URL: #7235
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
Trott committed Jun 11, 2016
1 parent 2bc7841 commit f2c59d9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,17 @@ For example: `'#hash'`
added: v0.1.25
-->

* `urlObject` {Object} A URL object (either as returned by `url.parse()` or
constructed otherwise).
* `urlObject` {Object | String} A URL object (as returned by `url.parse()` or
constructed otherwise). If a string, it is converted to an object by passing
it to `url.parse()`.

The `url.format()` method processes the given URL object and returns a formatted
URL string.
The `url.format()` method returns a formatted URL string derived from
`urlObject`.

The formatting process essentially operates as follows:
If `urlObject` is not an object or a string, `url.parse()` will throw a
[`TypeError`][].

The formatting process operates as follows:

* A new empty string `result` is created.
* If `urlObject.protocol` is a string, it is appended as-is to `result`.
Expand Down Expand Up @@ -247,3 +251,4 @@ forward slash (`/`) character is encoded as `%3C`.

[`Error`]: errors.html#errors_class_error
[`querystring`]: querystring.html
[`TypeError`]: errors.html#errors_class_typeerror

0 comments on commit f2c59d9

Please sign in to comment.