urlutil

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package urlutil provides URL validation and integrity-hash utilities shared by config (agent entry validation) and harness (remote resource resolution) packages. It lives at the leaf of the import graph to avoid the config → harness circular dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMintURL added in v0.57.0

func IsMintURL(raw string) bool

IsMintURL reports whether raw is acceptable as a token mint URL: https with a non-empty host, or plain http when the host is "localhost" or "127.0.0.1". It mirrors the loopback rule internal/mintclient applies when it sends a request, so config validation accepts the same local mint that the client would call. URLs with userinfo are rejected.

func IsURL

func IsURL(s string) bool

IsURL returns true if s is a valid HTTPS URL suitable for remote resource references.

func MatchingAllowedPrefixInList

func MatchingAllowedPrefixInList(rawURL string, allowlist []string) string

MatchingAllowedPrefixInList checks if a URL matches any prefix in the given allowlist. Returns the matching prefix or "" if none match. Performs case-insensitive comparison with percent-decoding and dot-segment cleaning.

func NormalizeURLPath

func NormalizeURLPath(rawURL string) (string, bool)

NormalizeURLPath parses a URL, percent-decodes and cleans its path, and returns the reconstructed URL string. Returns false if parsing fails.

func ParseIntegrityHash

func ParseIntegrityHash(rawURL string) (cleanURL, hash string, hasHash bool)

ParseIntegrityHash extracts the SHA256 hash from a URL fragment (#sha256=...). Returns the URL without the fragment, the hash value, and whether a valid hash was found. The hash is normalized to lowercase; both "sha256=ABC..." and "sha256=abc..." are accepted.

Types

This section is empty.

Jump to

Keyboard shortcuts

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