Documentation claims that the WHATWG URL API should behave the same in Node.js and in a Browser, but here is a counterexample:
console.log(new URL('http://exa mple.com').origin)
Run this in the browser (or here on stack overflow) and you get http://exa%20mple.com
Run this in Node.js (or here on RunKit) https://runkit.com/embed/cfo21jyrrvxq and you get TypeError: Invalid URL
The browser’s output is incorrect, that is not a valid URL. Is there a way to make the browser behave like Node.js? I would prefer a long-term standards-compliant solution to just installing another package.