Fix path pattern, again

This commit is contained in:
Ferran Basora 2019-05-02 16:26:02 +00:00
parent e1f50601e1
commit b900325319

View File

@ -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]