mirror of
https://github.com/FliegendeWurst/tmux-thumbs.git
synced 2024-11-24 05:45:00 +00:00
Support paths with $ symbols
It is quite common in some web frameworks (NextJS, Remix) to define routes with `$` on them. Adding support for paths that represent those routes.
This commit is contained in:
parent
760687263d
commit
2dc167218f
13
src/state.rs
13
src/state.rs
@ -14,7 +14,7 @@ const PATTERNS: [(&'static str, &'static str); 15] = [
|
||||
("diff_a", r"--- a/([^ ]+)"),
|
||||
("diff_b", r"\+\+\+ b/([^ ]+)"),
|
||||
("docker", r"sha256:([0-9a-f]{64})"),
|
||||
("path", r"(?P<match>([.\w\-@~\[\]]+)?(/[.\w\-@\[\]]+)+)"),
|
||||
("path", r"(?P<match>([.\w\-@$~\[\]]+)?(/[.\w\-@$\[\]]+)+)"),
|
||||
("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}"),
|
||||
("ipfs", r"Qm[0-9a-zA-Z]{44}"),
|
||||
@ -255,6 +255,17 @@ mod tests {
|
||||
assert_eq!(results.get(2).unwrap().text.clone(), "../log/kern.log");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_routes() {
|
||||
let lines = split("Lorem /app/routes/$routeId/$objectId, lorem\n Lorem /app/routes/$sectionId");
|
||||
let custom = [].to_vec();
|
||||
let results = State::new(&lines, "abcd", &custom).matches(false, false);
|
||||
|
||||
assert_eq!(results.len(), 2);
|
||||
assert_eq!(results.get(0).unwrap().text.clone(), "/app/routes/$routeId/$objectId");
|
||||
assert_eq!(results.get(1).unwrap().text.clone(), "/app/routes/$sectionId");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_home() {
|
||||
let lines = split("Lorem ~/.gnu/.config.txt, lorem");
|
||||
|
Loading…
Reference in New Issue
Block a user