Sync docs to Wiki / wiki (push) Has been cancelled
Signed-off-by: Stan Grams <sjg@haxx.space>
24 lines
594 B
Rust
24 lines
594 B
Rust
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
|
|
//
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
/// Normalize a name to lowercase alphanumeric.
|
|
pub fn normalize_name(name: &str) -> String {
|
|
name.to_ascii_lowercase()
|
|
.chars()
|
|
.filter(|c| c.is_ascii_alphanumeric())
|
|
.collect()
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_normalize_name() {
|
|
assert_eq!(normalize_name("FT-817"), "ft817");
|
|
assert_eq!(normalize_name("HTTP-JSON"), "httpjson");
|
|
assert_eq!(normalize_name("foo_bar-baz"), "foobarbaz");
|
|
}
|
|
}
|