Fix path with ~

This commit is contained in:
Ferran Basora 2020-05-04 17:15:00 +00:00
parent 122c26b8b0
commit 53af67e6fa
2 changed files with 13 additions and 1 deletions

View File

@ -22,6 +22,8 @@ path: /var/log/nginx.log
path: ./folder/.neomake@04fd.log path: ./folder/.neomake@04fd.log
home: ~/.gnu/.config.txt
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 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

View File

@ -9,7 +9,7 @@ const PATTERNS: [(&'static str, &'static str); 13] = [
("url", r"((https?://|git@|git://|ssh://|ftp://|file:///)[^ ]+)"), ("url", r"((https?://|git@|git://|ssh://|ftp://|file:///)[^ ]+)"),
("diff_a", r"--- a/([^ ]+)"), ("diff_a", r"--- a/([^ ]+)"),
("diff_b", r"\+\+\+ b/([^ ]+)"), ("diff_b", r"\+\+\+ b/([^ ]+)"),
("path", r"(([.\w\-@]+)?(/[.\w\-@]+)+)"), ("path", r"(([.\w\-@~]+)?(/[.\w\-@]+)+)"),
("color", r"#[0-9a-fA-F]{6}"), ("color", r"#[0-9a-fA-F]{6}"),
("uid", r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"), ("uid", r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"),
("ipfs", r"Qm[0-9a-zA-Z]{44}"), ("ipfs", r"Qm[0-9a-zA-Z]{44}"),
@ -224,6 +224,16 @@ mod tests {
assert_eq!(results.get(2).unwrap().text.clone(), "../log/kern.log"); assert_eq!(results.get(2).unwrap().text.clone(), "../log/kern.log");
} }
#[test]
fn match_home() {
let lines = split("Lorem ~/.gnu/.config.txt, lorem");
let custom = [].to_vec();
let results = State::new(&lines, "abcd", &custom).matches(false, false);
assert_eq!(results.len(), 1);
assert_eq!(results.get(0).unwrap().text.clone(), "~/.gnu/.config.txt");
}
#[test] #[test]
fn match_uids() { fn match_uids() {
let lines = split("Lorem ipsum 123e4567-e89b-12d3-a456-426655440000 lorem\n Lorem lorem lorem"); let lines = split("Lorem ipsum 123e4567-e89b-12d3-a456-426655440000 lorem\n Lorem lorem lorem");