urlredact

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package urlredact keeps a secret that a URL carries (a token in the path, credentials in the user info or the query) out of an error or a log line.

Index

Constants

View Source
const RedactedURL = "[REDACTED]"

RedactedURL replaces the URL of an error that must not leak it.

Variables

This section is empty.

Functions

func RedactURL

func RedactURL(raw string) string

RedactURL returns a URL that is safe to put in an error or a log: only the scheme and the host are kept. The user info, the path (tokens are sometimes carried by it), the query string and the fragment may carry credentials, so they are dropped. A value that can not be parsed is replaced entirely, because its content is unknown.

func RedactURLError

func RedactURLError(err error) error

RedactURLError removes the URLs from the errors returned by net/http and net/url.

Those errors embed the full request URL, but the URL of a webhook (Slack, Discord, ...) or of an endpoint may carry a secret (token in the path, credentials in the user info or in the query string). The operation and the root cause are kept so the error stays actionable. When the cause itself quotes a URL (for example a malformed redirect Location header), the cause is rewritten without it. The cause of a parse error is always replaced, because it quotes the unparsable input.

Types

This section is empty.

Jump to

Keyboard shortcuts

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