Skip to main content

redact

Function redact 

Source
pub fn redact(text: &str) -> String
Expand description

Replaces values that change on every run by placeholders, so a snapshot or an assert_eq! on a whole page or JSON body is stable (Loco’s cleanup_* filters): UUIDs become <UUID>, ISO 8601 dates and times (2026-01-01, 2026-01-01T12:00:00Z, 2026-01-01 12:00:00) become <DATE>, and runs of 32 or more hexadecimal or base64url characters (tokens, digests) become <TOKEN>.

§Examples

let body = r#"{"id":"123e4567-e89b-42d3-a456-426614174000","at":"2026-09-29T10:00:00Z"}"#;
assert_eq!(ocre::testing::redact(body), r#"{"id":"<UUID>","at":"<DATE>"}"#);