site

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package site computes what browsers call a site: a scheme and a registrable domain (public suffix list), the unit of SameSite cookies, sec-fetch-site and cookie partitions; and the ASCII form of a host name (ASCII), in which browsers send and match it.

Registrable and Of are memoized per host: every request asks for them several times (sec-fetch-site, the cookie jar's SameSite context), and computing them allocates (the public suffix lookup, the IP parse).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ASCII added in v0.3.0

func ASCII(domain string) (string, error)

ASCII returns domain as browsers send it and match cookies against: lowercase, and a name with non-ASCII characters through UTS #46 ToASCII ("Bücher.de" is "xn--bcher-kva.de"), an error when that fails. An ASCII name is only lowercased.

func CheckLabels added in v0.4.0

func CheckLabels(domain string) error

CheckLabels runs domain, ASCII, through UTS #46 ToASCII as a non-ASCII one is, for its error: an "xn--" label that is not valid punycode fails it, as Firefox refuses such a host (profile.URLs.CheckPunycode).

func IsPublicSuffix

func IsPublicSuffix(domain string) bool

IsPublicSuffix reports whether domain is a public suffix ("com", "co.uk"), where no cookie may be set for a whole domain.

func Loopback

func Loopback(host string) bool

Loopback reports a loopback host (Secure Contexts): localhost, a name under .localhost, or a loopback IP address.

func Of

func Of(u *url.URL) string

Of returns u's schemeful site, "https://example.com".

func Registrable

func Registrable(host string) string

Registrable returns host's registrable domain (eTLD+1), or the host itself for IP addresses and hosts without one.

func Same

func Same(a, b *url.URL) bool

Same reports whether a and b are the same schemeful site.

func Trustworthy

func Trustworthy(u *url.URL) bool

Trustworthy reports a potentially trustworthy URL (Secure Contexts): https or wss, or a loopback host.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL