redactParsedUrlCredentials
Это содержимое пока не доступно на вашем языке.
redactParsedUrlCredentials(
url):string
Defined in: src/util/RedactUrlCredentials.ts:354
url as its own href, with the username and the password replaced by
*** — exactly those two, found by length rather than by a search.
For the URL a runtime actually uses — the one a request went to, or a
redirect target resolved against the request that received it — WHATWG’s
username and password are exactly the credential that travels, so
masking those two cannot leak and cannot over-mask (found while #1458).
redactUrlCredentials has no parse to go by, reads up to the last @
before the next :// as userinfo, and so hands back
https://registry.npmjs.org/@types%2fnode as https://***@types%2fnode;
here it comes back as it is.
What follows the host — path, query, fragment — still goes through
redactUrlCredentials. A URL written into it
(?target=http://user:pass@inner/x) is text the parsed one carries, and
nothing split that text’s userinfo from its host: masking only the outer
credential would print the inner one whole, which the scan never did. An
@ with no :// in front of it, as in the registry path above, the scan
leaves alone.
Only for a URL a request is made with, or would be. Parsing a configured
string just to render it turns the trade around: a mistyped password with an
unescaped / in it parses as a host, a port and a path (user:12/PW1@host),
so the parse prints the very password it was meant to hide. A value that
has not been parsed for a request, or does not parse at all, goes through
redactUrlCredentials. And the result is normalised as href is —
lowercased host, encoded path — because it names what the runtime sends,
not what an operator typed.
Parameters
Section titled “Parameters”URL
Returns
Section titled “Returns”string
