urlallow

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package urlallow is the single source of truth for the URL allowlist dotvault applies before handing a URL to an OS opener or a notification backend: an absolute http or https URL with a real host and no embedded credentials.

It exists so the two surfaces that gate a URL against an OS action — the remote-browse endpoint (internal/web) and the notification action link (internal/notify) — enforce byte-for-byte the same rule from one implementation. internal/web imports internal/notify, so notify could not import web to reuse its validator; a shared leaf package both import breaks that would-be cycle and keeps the "same allowlist" invariant the docs advertise actually enforced rather than duplicated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(raw string) (*url.URL, error)

Validate enforces the allowlist: the value must parse as an absolute http or https URL with a host and no embedded user:pass@ credentials. Everything else — file://, custom protocol handlers (vscode:, ssh:), javascript:/data:, scheme-relative or bare paths, userinfo forms — is rejected, because the URL is handed to an OS opener (xdg-open / `open` / ShellExecute) or a native notification backend, which would otherwise dispatch a non-web scheme to an arbitrary local handler or carry credentials into the launcher and its logs. It returns the parsed URL so callers never re-parse (the canonical string form is u.String(), which lowercases the scheme and percent-encodes hostile characters). A leading/trailing space is trimmed; an empty input is an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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