Push `url` (what follows `scheme://`, up to whitespace) without its credentials.
(out: &mut String, url: &str)
| 23 | /// Push `url` (what follows `scheme://`, up to whitespace) without its |
| 24 | /// credentials. |
| 25 | fn push_redacted(out: &mut String, url: &str) { |
| 26 | let host_and_rest = match url.rfind('@') { |
| 27 | Some(at) => { |
| 28 | out.push_str("***@"); |
| 29 | &url[at + 1..] |
| 30 | } |
| 31 | None => url, |
| 32 | }; |
| 33 | let end = host_and_rest |
| 34 | .find(['?', '#']) |
| 35 | .unwrap_or(host_and_rest.len()); |
| 36 | out.push_str(&host_and_rest[..end]); |
| 37 | } |
| 38 | |
| 39 | #[cfg(test)] |
| 40 | mod tests { |