pub struct UrlPasswordRedactor;Expand description
Redact the password component of a URL, preserving all other components.
If the URL contains a password component, it is replaced with ***. All other components —
scheme, username, host, port, path, query, fragment — are preserved. The output is the URL as
normalised by the url crate (for example, a trailing / may be added to URLs with an
authority and no path, and an empty password is dropped entirely along with its : separator).
If the input cannot be parsed as a URL, the output is [REDACTED: invalid URL].
use apollo_redaction::Redacted;
use apollo_redaction::strategy::UrlPasswordRedactor;
fn url(input: &str) -> String {
Redacted::<_, UrlPasswordRedactor>::new(input).to_string()
}
assert_eq!(url("http://alice:s3cr3t@proxy.corp.example.com:3128/"), "http://alice:***@proxy.corp.example.com:3128/");
assert_eq!(url("postgres://user:hunter2@db.internal/app"), "postgres://user:***@db.internal/app");
assert_eq!(url("http://proxy.example.com:3128"), "http://proxy.example.com:3128/");
assert_eq!(url("not a url"), "[REDACTED: invalid URL]");Trait Implementations§
Source§impl Clone for UrlPasswordRedactor
impl Clone for UrlPasswordRedactor
Source§fn clone(&self) -> UrlPasswordRedactor
fn clone(&self) -> UrlPasswordRedactor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for UrlPasswordRedactor
impl Default for UrlPasswordRedactor
Source§fn default() -> UrlPasswordRedactor
fn default() -> UrlPasswordRedactor
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for UrlPasswordRedactor
impl RefUnwindSafe for UrlPasswordRedactor
impl Send for UrlPasswordRedactor
impl Sync for UrlPasswordRedactor
impl Unpin for UrlPasswordRedactor
impl UnsafeUnpin for UrlPasswordRedactor
impl UnwindSafe for UrlPasswordRedactor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more