A base URL. Data paths are appended to it as WHATWG parses it (new URL(value).href), so
every reader of the value has to agree with that parse:
blank is refused (only an omitted base URL selects the default host);
surrounding whitespace is refused: new URL() trims it silently, so the URL requested
would not be the one typed;
only http:/https: are accepted: a file:/ftp: value fails here, as a
configuration mistake, rather than deep in a (possibly custom) transport;
a ? or # would swallow every path (http://h/?x requests /?x/dam/...,
http://h/#f requests /).
a control character is refused: new URL() drops tab/CR/LF silently;
userinfo (user:pass@) is allowed, but it must decode: Node decodes it into the
Authorization header and fails at request time ("URI malformed", reported as a
network error) on a % that isn't an escape, so that is a usage error here
(write a literal % as %25);
a backslash is refused: WHATWG reads it as "/" in an http(s) URL, so it ends the host
(https://u:pw@a.example\@b.example sends u:pw to a.example), where a reader of the
text would see another;
a scheme not followed by exactly // and the host (http:host, http:/host,
http:///host) is refused: WHATWG repairs it into http://host silently.
The reasons never echo the URL, so a credential in it cannot leak; error messages
redact the userinfo.
A base URL. Data paths are appended to it as WHATWG parses it (
new URL(value).href), so every reader of the value has to agree with that parse:blank is refused (only an omitted base URL selects the default host);
surrounding whitespace is refused:
new URL()trims it silently, so the URL requested would not be the one typed;only
http:/https:are accepted: afile:/ftp:value fails here, as a configuration mistake, rather than deep in a (possibly custom) transport;a
?or#would swallow every path (http://h/?xrequests/?x/dam/...,http://h/#frequests/).a control character is refused:
new URL()drops tab/CR/LF silently;userinfo (
user:pass@) is allowed, but it must decode: Node decodes it into the Authorization header and fails at request time ("URI malformed", reported as a network error) on a%that isn't an escape, so that is a usage error here (write a literal%as%25);a backslash is refused: WHATWG reads it as "/" in an http(s) URL, so it ends the host (
https://u:pw@a.example\@b.examplesendsu:pwto a.example), where a reader of the text would see another;a scheme not followed by exactly
//and the host (http:host,http:/host,http:///host) is refused: WHATWG repairs it intohttp://hostsilently.The reasons never echo the URL, so a credential in it cannot leak; error messages redact the userinfo.