@@ -1739,9 +1739,8 @@ changes:
17391739 times.
17401740-->
17411741
1742- * ` urlObject` {Object|string} A URL object (as returned by ` url.parse()` or
1743- constructed otherwise). If a string, it is converted to an object by passing
1744- it to ` url.parse()` .
1742+ * ` urlObject` {Object} A URL object (as returned by ` url.parse()` or
1743+ constructed otherwise).
17451744
17461745The ` url .format ()` method returns a formatted URL string derived from
17471746` urlObject` .
@@ -1822,6 +1821,48 @@ An automated migration is available ([source](https://github.com/nodejs/userland
18221821npx codemod@latest @nodejs/node-url-to-whatwg-url
18231822```
18241823
1824+ ### `url.format(urlString)`
1825+
1826+ <!-- YAML
1827+ added: v0.1.25
1828+ changes:
1829+ - version:
1830+ - v24.0.0
1831+ pr-url: https://github.com/nodejs/node/pull/55017
1832+ description: Application deprecation.
1833+ -->
1834+
1835+ > Stability: 0 - Deprecated: Use the WHATWG URL API instead.
1836+
1837+ * `urlString` {string} A string that will be passed to `url.parse()` and then
1838+ formatted.
1839+
1840+ `url.format(urlString)` is shorthand for `url.format(url.parse(urlString))`.
1841+
1842+ Because it invokes the deprecated [`url.parse()`][], passing a string argument
1843+ to `url.format()` is itself deprecated.
1844+
1845+ Canonicalizing a URL string can be performed using the WHATWG URL API, by
1846+ constructing a new URL object and calling [`url.toString()`][].
1847+
1848+ ```mjs
1849+ import { URL } from ' node: url' ;
1850+
1851+ const unformatted = ' http: // [fe80:0:0:0:0:0:0:1]:/a/b?a=b#abc';
1852+ const formatted = new URL (unformatted).toString ();
1853+
1854+ console .log (formatted); // Prints: http://[fe80::1]/a/b?a=b#abc
1855+ ` ` `
1856+
1857+ ` ` ` cjs
1858+ const { URL } = require (' node:url' );
1859+
1860+ const unformatted = ' http://[fe80:0:0:0:0:0:0:1]:/a/b?a=b#abc' ;
1861+ const formatted = new URL (unformatted).toString ();
1862+
1863+ console .log (formatted); // Prints: http://[fe80::1]/a/b?a=b#abc
1864+ ` ` `
1865+
18251866### ` url .parse (urlString[, parseQueryString[, slashesDenoteHost]])`
18261867
18271868<!-- YAML
0 commit comments