Skip to main content

Module urls

Module urls 

Source
Expand description

Small, allocation-light helpers for operator-configured URLs: showing them without credentials, and comparing where they point.

A URL such as https://user:token@collector.example/v1/traces carries a credential in its userinfo. Hosts print URLs in startup lines, errors and Debug output, so they pass them through redact_userinfo first. The parsing here is deliberately simple (scheme, authority, rest): it is for display and same-host checks of http(s) URLs, not a full RFC 3986 parser.

Constants§

REDACTED_USERINFO
Replacement shown for a URL’s userinfo.

Functions§

host
The host of an http(s) URL: lowercase, without userinfo, port or IPv6 brackets.
is_cleartext_remote
Whether url is plain http:// to a host other than this machine, where credentials would cross the network in clear text.
is_loopback_host
Whether host names this machine: localhost or a loopback IP address.
origin
scheme://host:port of an http(s) URL, lowercase, with the default port filled in, so https://A.example and https://a.example:443/x compare equal.
redact_userinfo
url with any user:password@ replaced by ***@.