weburl

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package weburl checks URLs that people store and other people's browsers load or follow: organization logos and websites, and avatars.

Index

Constants

View Source
const MaxLen = 2048

MaxLen is the longest URL accepted.

Variables

View Source
var ErrNotHTTPS = errors.New("must be an absolute https URL")

ErrNotHTTPS is returned for a URL that is not an absolute https URL.

Functions

func CheckHTTPS

func CheckHTTPS(raw string) error

CheckHTTPS returns nil when raw is empty, which clears the field, or an absolute https URL with a host, no user info, no control characters and at most MaxLen bytes. Anything else, such as "javascript:", "data:" or "http:", returns ErrNotHTTPS: a stored URL is loaded or followed by every browser that shows it.

func HTTPSOrEmpty

func HTTPSOrEmpty(raw string) string

HTTPSOrEmpty returns raw when CheckHTTPS accepts it, and "" otherwise. Use it for values copied from an identity provider, where an unusable URL should be dropped rather than fail the sign-in.

Types

This section is empty.

Jump to

Keyboard shortcuts

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