MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / urls

Function urls

atomic-cli/src/logging/redact.rs:8–21  ·  view source on GitHub ↗

Strip credentials from URLs before text reaches the log file. `text` with every URL's credentials removed: everything up to the last `@` becomes `***@`, and the query and fragment are dropped. Remote errors name the URL they failed on, remote URLs can carry credentials in either place, and an "invalid URL" error may quote one too malformed to parse, so this over-redacts rather than parsing.

(text: &str)

Source from the content-addressed store, hash-verified

6/// place, and an "invalid URL" error may quote one too malformed to parse,
7/// so this over-redacts rather than parsing.
8pub(crate) fn urls(text: &str) -> String {
9 let mut out = String::with_capacity(text.len());
10 let mut rest = text;
11 while let Some(at) = rest.find("://") {
12 let (before, after) = rest.split_at(at + "://".len());
13 out.push_str(before);
14 let end = after.find(char::is_whitespace).unwrap_or(after.len());
15 let (url, tail) = after.split_at(end);
16 push_redacted(&mut out, url);
17 rest = tail;
18 }
19 out.push_str(rest);
20 out
21}
22
23/// Push `url` (what follows `scheme://`, up to whitespace) without its
24/// credentials.

Callers 1

describe_sourceFunction · 0.85

Calls 2

push_redactedFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected