Skip to content

url: extend url.format to support WHATWG URL

Removes the non-standard options on WHATWG URL toString and extends the existing url.format() API to support customizable serialization of the WHATWG URL object.

This does not yet include the documentation updates because the documentation for the new WHATWG URL object has not yet landed.

Example:

const url = require('url');
const URL = url.URL;
const myURL = new URL('http://example.org/?a=b#c');
const str = url.format(myURL, {fragment: false, search: false});
console.log(str);
  // Prints: http://example.org/
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

url, whatwg-url

/cc @watilde @nodejs/url

Merge request reports

Loading