Skip to main content

slugify

Function slugify 

Source
pub fn slugify(name: &str) -> String
Expand description

Normalize a page name into a slug.

Rules:

  • Lowercase
  • Trim whitespace
  • Split on / and normalize each segment independently
  • Within each segment: replace spaces and underscores with hyphens, strip punctuation, collapse consecutive hyphens, trim leading/trailing hyphens
  • Preserve Unicode alphanumeric characters
  • Drop empty segments (handles //, leading /, trailing /)
  • Rejoin with /