relay_event_normalization::span::description

Function scrub_domain_name

source
pub fn scrub_domain_name(domain: &str) -> Cow<'_, str>
Expand description

Sanitize a qualified domain string.

Replace all but the last two segments with asterisks. Returns a string. In cases where the string is not domain-like, returns the original string.

ยงExamples

use relay_event_normalization::span::description::scrub_domain_name;

assert_eq!(scrub_domain_name("my.domain.com"), "*.domain.com");
assert_eq!(scrub_domain_name("data.bbc.co.uk"), "*.bbc.co.uk");
assert_eq!(scrub_domain_name("hello world"), "hello world");