MCPcopy Index your code
hub / github.com/coder/coder / RedactURL

Function RedactURL

coderd/x/chatd/mcpclient/mcpclient.go:466–475  ·  view source on GitHub ↗

RedactURL strips userinfo and query parameters from a URL to avoid logging embedded credentials. Query params are removed because API keys are sometimes passed as ?api_key=sk-... in server URLs.

(rawURL string)

Source from the content-addressed store, hash-verified

464// removed because API keys are sometimes passed as
465// ?api_key=sk-... in server URLs.
466func RedactURL(rawURL string) string {
467 u, err := url.Parse(rawURL)
468 if err != nil {
469 return rawURL
470 }
471 u.User = nil
472 u.RawQuery = ""
473 u.Fragment = ""
474 return u.String()
475}
476
477// redactErrorURL rewrites URLs in an error string to strip
478// credentials. Go's net/http embeds the full request URL in

Callers 3

TestRedactURLFunction · 0.92
ConnectAllFunction · 0.85
redactErrorURLFunction · 0.85

Calls 2

ParseMethod · 0.65
StringMethod · 0.45

Tested by 1

TestRedactURLFunction · 0.74