From 673c0dbde1c7f3c45b1219c90e4a6b4662472bbf Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Mon, 25 Feb 2019 19:24:51 +0000 Subject: [PATCH] Improve path regexp --- src/state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/state.rs b/src/state.rs index bb2177d..b75ff46 100644 --- a/src/state.rs +++ b/src/state.rs @@ -34,7 +34,7 @@ impl<'a> State<'a> { let mut patterns = Vec::new(); patterns.push(Regex::new(r"((https?://|git@|git://|ssh://|ftp://|file:///)[\w?=%/_.:,;~@!#$&()*+-]*)").unwrap()); // Urls - patterns.push(Regex::new(r"/[^ ]+").unwrap()); // Paths + patterns.push(Regex::new(r"[^ ]+/[^ ]+").unwrap()); // Paths patterns.push(Regex::new(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").unwrap()); // Uid patterns.push(Regex::new(r"[0-9a-f]{7,40}").unwrap()); // Sha id patterns.push(Regex::new(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}").unwrap()); // Ip address @@ -145,7 +145,7 @@ mod tests { #[test] fn match_paths () { - let output = "Lorem /tmp/foo/bar lorem\n Lorem /var/log/bootstrap.log lorem /var/log/kern.log lorem"; + let output = "Lorem /tmp/foo/bar lorem\n Lorem /var/log/bootstrap.log lorem ../log/kern.log lorem"; assert_eq!(match_lines(output).len(), 3); }