From 4be4032055dea2a1205f19efc5e0685f0afe739d Mon Sep 17 00:00:00 2001 From: Jonathan Flueren Date: Fri, 7 Jul 2023 11:58:20 +0200 Subject: [PATCH] 0.1.1: ignore if first letter is non-alphabetic --- Cargo.toml | 2 +- src/lib.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 258f751..226a772 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "schmfy" -version = "0.1.0" +version = "0.1.1" edition = "2021" license = "MIT OR Apache-2.0" description = "Schmfication library" diff --git a/src/lib.rs b/src/lib.rs index 17620d3..4ce5b0e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,15 @@ pub fn schmfy(source: String) -> String { return source; } + if source.len() == 0 { + return source; + } + + // can't be empty + if !source.chars().next().unwrap().is_alphabetic() { + return source; + } + // if source is subsite (e.g. news/fsr), schmfy all parts separately if source.contains('/') { return source