From 2ac8bc25ca045d1c8e4091e19d848359bb4e15d8 Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Thu, 3 Oct 2019 16:12:38 +0000 Subject: [PATCH] Match @ in paths --- samples/test1 | 2 ++ src/state.rs | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/samples/test1 b/samples/test1 index 8a2d4ec..8cebc79 100644 --- a/samples/test1 +++ b/samples/test1 @@ -20,6 +20,8 @@ ipsum [fcsonline](https://github.com/fcsonline) lorem path: /var/log/nginx.log +path: ./folder/.neomake@04fd.log + 10.3.23.42 lorem 123.2.3.4 lorem 230.23.33.34 10.3.23.42 lorem 123.2.3.4 lorem 230.23.33.34 10.3.23.42 lorem 123.2.3.4 lorem 230.23.33.34 diff --git a/src/state.rs b/src/state.rs index f9dd6c0..b85801a 100644 --- a/src/state.rs +++ b/src/state.rs @@ -13,7 +13,7 @@ const PATTERNS: [(&'static str, &'static str); 12] = [ ), ("diff_a", r"--- a/([^ ]+)"), ("diff_b", r"\+\+\+ b/([^ ]+)"), - ("path", r"(([.\w-]+)?(/[.\w-]+)+)"), + ("path", r"(([.\w\-@]+)?(/[.\w\-@]+)+)"), ("color", r"#[0-9a-fA-F]{6}"), ( "uid", @@ -210,13 +210,14 @@ mod tests { #[test] fn match_bash() { - let lines = split("path: /var/log/nginx.log\npath: test/log/nginx.log:32"); + let lines = split("path: /var/log/nginx.log\npath: test/log/nginx-2.log:32folder/.nginx@4df2.log"); let custom = [].to_vec(); let results = State::new(&lines, "abcd", &custom).matches(false, false); - assert_eq!(results.len(), 2); - assert_eq!(results.first().unwrap().text, "/var/log/nginx.log"); - assert_eq!(results.last().unwrap().text, "test/log/nginx.log"); + assert_eq!(results.len(), 3); + assert_eq!(results.get(0).unwrap().text, "/var/log/nginx.log"); + assert_eq!(results.get(1).unwrap().text, "test/log/nginx-2.log"); + assert_eq!(results.get(2).unwrap().text, "folder/.nginx@4df2.log"); } #[test]