redact

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package redact provides utilities for redacting sensitive information from URLs and errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuthUser

func BasicAuthUser(cred string) string

BasicAuthUser redacts the password from a basic auth credential string. "user:password" -> "user:REDACTED"

func ProxyPath

func ProxyPath(path string) string

ProxyPath redacts API key segments from proxy paths. /proxy/{api-key}/... -> /proxy/REDACTED/...

func String

func String(s string) string

String redacts sensitive information in any string. URLs found in the text get full URL redaction (query params, userinfo, path tokens); the remainder gets a regex pass for URL fragments. This is useful for sanitizing error messages that may contain URLs or URL fragments.

func URLError

func URLError(err error) error

URLError wraps a *url.Error (if present) with a redacted URL. If err is or wraps *url.Error, returns a cloned error with the URL redacted. Otherwise returns err unchanged.

func URLString

func URLString(raw string) string

URLString redacts sensitive query parameter values in a URL string. Also redacts userinfo passwords (user:pass@host), proxy path segments, credential-shaped path segments, and URLs nested in query values (magnet tr= announce URLs, redirect targets). If parsing fails, it uses a regex fallback to perform the same redaction.

Types

This section is empty.

Jump to

Keyboard shortcuts

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