Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cab6c8e

Browse filesBrowse files
zekeaddaleax
authored andcommitted
doc: add URL.format() example
PR-URL: #18888 Fixes: #18887 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent d883376 commit cab6c8e
Copy full SHA for cab6c8e

File tree

Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/url.md‎

Copy file name to clipboardExpand all lines: doc/api/url.md
+14Lines changed: 14 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,20 @@ changes:
971971
The `url.format()` method returns a formatted URL string derived from
972972
`urlObject`.
973973

974+
```js
975+
url.format({
976+
protocol: 'https',
977+
hostname: 'example.com',
978+
pathname: '/some/path',
979+
query: {
980+
page: 1,
981+
format: 'json'
982+
}
983+
});
984+
985+
// => 'https://example.com/some/path?page=1&format=json'
986+
```
987+
974988
If `urlObject` is not an object or a string, `url.format()` will throw a
975989
[`TypeError`][].
976990

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.