Skip to main content

sanitize_token

Function sanitize_token 

Source
pub(crate) fn sanitize_token(raw: &str) -> String
Expand description

Normalizes namespace text into a subject-safe token.

Trims the input, lowercases ASCII letters, keeps ASCII digits, - and _, turns whitespace, . and / into -, and drops every other character. Leading and trailing - are removed.

§Arguments

  • raw - Text to normalize, such as a box id.

§Returns

The normalized token, or unknown if nothing is left.

§Examples

sanitize_token(" MU1.Box ") == "mu1-box"
sanitize_token("***")       == "unknown"