Lowercase only first char when normalizing

This commit is contained in:
Joscha 2022-10-22 00:01:04 +02:00
parent 3a75089e5a
commit a9435e4f64

View file

@ -1,3 +1,11 @@
pub fn normalize_link(link: &str) -> String {
link.trim().to_lowercase().replace(' ', "_")
let link = link.trim().replace(' ', "_");
// Make only first char lowercase
link.chars()
.next()
.iter()
.flat_map(|c| c.to_lowercase())
.chain(link.chars().skip(1))
.collect::<String>()
}