Documentation
¶
Overview ¶
Package urlcanon implements AdCP URL-identifier canonicalization, the single normalization an AdCP implementation applies before comparing two URLs for identity (e.g. matching a seller_agent_url to its registered active package set, or computing the RFC 9421 @target-uri signature component).
The algorithm is defined in the AdCP reference documentation at docs/reference/url-canonicalization. It is intentionally distinct from tmproto.CanonicalizeURL, which produces the url_hash content-dedup form (lowercased, query-sorted, fragment-stripped) used for artifact hashing — do not substitute one for the other.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BracketIfIPv6 ¶
BracketIfIPv6 wraps host in brackets when it parses as an IPv6 address literal. net.SplitHostPort strips the brackets; canonical authority keeps them.
func Canonicalize ¶
Canonicalize applies the AdCP URL-identifier canonicalization (docs/reference/url-canonicalization):
- Lowercase scheme.
- Lowercase host; IDN → Punycode (url.Parse handles Punycode already).
- Strip userinfo.
- Strip default ports (:443 for https, :80 for http).
- remove_dot_segments on path; empty path with authority becomes "/".
- Normalize percent-encoding: decode unreserved octets, uppercase the hex of reserved ones.
- Preserve query byte-for-byte.
- Strip fragment.
rawURL is the URL as received on the wire. For outgoing signed requests the signer supplies the URL string it will send; for incoming, the verifier reconstructs it from scheme + Host + RequestURI.
func IsDefaultPort ¶
IsDefaultPort reports whether port is the default for scheme (443 for https, 80 for http) and may therefore be stripped from a canonical authority.
Types ¶
This section is empty.