diff options
author | Kornel <kornel@geekhood.net> | 2019-08-05 04:07:33 +0100 |
---|---|---|
committer | Kornel <kornel@geekhood.net> | 2019-08-05 04:07:33 +0100 |
commit | bc06fb2a2d8cb4b2a53f082b610e69a16e0d79f8 (patch) | |
tree | c16a2d6eddcb1a8573317e4f8802e79af6b370d3 /categories/src | |
parent | 53e49237d4a8f0be10abf110c26bcc1e7f91216e (diff) |
Fix categories filtering
Diffstat (limited to 'categories/src')
-rw-r--r-- | categories/src/categories.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/categories/src/categories.rs b/categories/src/categories.rs index 7840457..367e940 100644 --- a/categories/src/categories.rs +++ b/categories/src/categories.rs @@ -127,6 +127,7 @@ impl Categories { pub fn fixed_category_slugs(cats: &[String]) -> Vec<Cow<'_, str>> { let mut cats = Self::filtered_category_slugs(cats).enumerate().filter_map(|(idx, s)| { + let s = s.trim_matches(':'); let mut chars = s.chars().peekable(); while let Some(cur) = chars.next() { // look for a:b instead of a::b @@ -150,6 +151,12 @@ impl Categories { } let depth = s.split("::").count(); Some((depth, idx, Cow::Borrowed(s.as_ref()))) + }).filter(|(_, _, s)| { + if CATEGORIES.from_slug(s).next().is_none() { + println!("invalid cat name {}", s); + return false; + } + true }).collect::<Vec<_>>(); // depth, then original order |