redact

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 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 query parameter values in any string using regex. Also redacts userinfo passwords and proxy path segments. 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 passwords in userinfo (user:pass@host) and proxy path segments. If the URL can be parsed, it replaces values of known sensitive parameters with REDACTED. 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