From b900325319005708d4caa2640784ae9fffecf705 Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Thu, 2 May 2019 16:26:02 +0000 Subject: [PATCH] Fix path pattern, again --- src/state.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/state.rs b/src/state.rs index 642b16b..aa51283 100644 --- a/src/state.rs +++ b/src/state.rs @@ -13,7 +13,7 @@ const PATTERNS: [(&'static str, &'static str); 11] = [ ), ("diff_a", r"--- a/([^ ]+)"), ("diff_b", r"\+\+\+ b/([^ ]+)"), - ("path", r"/?[^ :/]+/[^: [[:cntrl:]]]+"), + ("path", r"(([.\w-]+)?(/[.\w-]+)+)"), ("color", r"#[0-9a-fA-F]{6}"), ( "uid", @@ -221,11 +221,14 @@ mod tests { #[test] fn match_paths() { let lines = - split("Lorem /tmp/foo/bar lorem\n Lorem /var/log/bootstrap.log lorem ../log/kern.log lorem"); + split("Lorem /tmp/foo/bar_lol, lorem\n Lorem /var/log/boot-strap.log lorem ../log/kern.log lorem"); let custom = [].to_vec(); let results = State::new(&lines, "abcd", &custom).matches(false, false); assert_eq!(results.len(), 3); + assert_eq!(results.get(0).unwrap().text.clone(), "/tmp/foo/bar_lol"); + assert_eq!(results.get(1).unwrap().text.clone(), "/var/log/boot-strap.log"); + assert_eq!(results.get(2).unwrap().text.clone(), "../log/kern.log"); } #[test]