diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-08-25 12:15:41 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-08-25 12:31:58 +0200 |
commit | f4c27710d87af3652490cda63328715d44adb940 (patch) | |
tree | 8358fbf426e88d19c7584325b8baf64cd053e0bf /lib/entry | |
parent | f4fa8b71dd890fe1e34f2abb32e1211f84da4dcf (diff) |
Fix: Do not check via regex
We do not need to check via regex here, because the previous checks are
already more restrictive than the regex itself.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'lib/entry')
-rw-r--r-- | lib/entry/libimagentrytag/src/tag.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/entry/libimagentrytag/src/tag.rs b/lib/entry/libimagentrytag/src/tag.rs index c9607bb5..58573cef 100644 --- a/lib/entry/libimagentrytag/src/tag.rs +++ b/lib/entry/libimagentrytag/src/tag.rs @@ -19,7 +19,6 @@ use std::result::Result; -use regex::Regex; use failure::Error; pub type Tag = String; @@ -37,9 +36,8 @@ pub fn is_tag_str(s: &String) -> Result<(), Error> { let is_lower = |s: &String| s.chars().all(|c| c.is_lowercase()); let no_whitespace = |s: &String| s.chars().all(|c| !c.is_whitespace()); let is_alphanum = |s: &String| s.chars().all(|c| c.is_alphanumeric()); - let matches_regex = |s: &String| Regex::new("^[a-zA-Z]([a-zA-Z0-9_-]*)$").unwrap().captures(s).is_some(); - if is_lower.and(no_whitespace).and(is_alphanum).and(matches_regex).filter(s) { + if is_lower.and(no_whitespace).and(is_alphanum).filter(s) { Ok(()) } else { Err(format_err!("The string '{}' is not a valid tag", s)) |