A configured base URL (baseUrl, --base-url): not blank, no surrounding
whitespace, a parseable http:/https: URL without a query or fragment.
Userinfo (https://user:pw@host/) is allowed; it is redacted from messages and sent
as Basic auth, so a % in it must start a valid escape (%25 for a literal one).
Requests go to the base URL as WHATWG parses it (the engine), so every rule makes sure that
reading is the one typed:
no surrounding whitespace (checked on the raw value) and no control character anywhere:
new URL() trims or drops them silently ("https://h/2 " read as https://h/2, a tab
inside a host dropped);
no ? or #: either would swallow every path (http://h/2?x=1 requests
/2?x=1/version, http://h/2#f requests /2);
no backslash: WHATWG ends an http(s) host at one, as at a /, while text-based code reads
on, so https://u:pw@a.example\@b.example was checked as one host and its credentials could
go to another;
the scheme followed by exactly // and the host (not http:host, http:/host or
http:///host): WHATWG skips any slashes after an http(s) scheme and repairs the URL
silently, so the host requested would not be the one typed either.
The reasons never repeat the value, nor a part of it, so a credential in it cannot reach a
message.
A configured base URL (
baseUrl,--base-url): not blank, no surrounding whitespace, a parseablehttp:/https:URL without a query or fragment. Userinfo (https://user:pw@host/) is allowed; it is redacted from messages and sent as Basic auth, so a%in it must start a valid escape (%25for a literal one).Requests go to the base URL as WHATWG parses it (the engine), so every rule makes sure that reading is the one typed:
new URL()trims or drops them silently ("https://h/2 "read ashttps://h/2, a tab inside a host dropped);?or#: either would swallow every path (http://h/2?x=1requests/2?x=1/version,http://h/2#frequests/2);/, while text-based code reads on, sohttps://u:pw@a.example\@b.examplewas checked as one host and its credentials could go to another;//and the host (nothttp:host,http:/hostorhttp:///host): WHATWG skips any slashes after an http(s) scheme and repairs the URL silently, so the host requested would not be the one typed either. The reasons never repeat the value, nor a part of it, so a credential in it cannot reach a message.