mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 16:10:07 +01:00
refactor: pattern ip -> ipv4
This commit is contained in:
parent
c57e78bb66
commit
75054d1200
2 changed files with 9 additions and 2 deletions
|
|
@ -360,7 +360,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn match_ips() {
|
fn match_ipv4s() {
|
||||||
let buffer = "Lorem ipsum 127.0.0.1 lorem\n Lorem 255.255.10.255 lorem 127.0.0.1 lorem";
|
let buffer = "Lorem ipsum 127.0.0.1 lorem\n Lorem 255.255.10.255 lorem 127.0.0.1 lorem";
|
||||||
let named_pat = vec![];
|
let named_pat = vec![];
|
||||||
let custom = vec![];
|
let custom = vec![];
|
||||||
|
|
@ -368,8 +368,11 @@ mod tests {
|
||||||
let results = Model::new(buffer, &alphabet, &named_pat, &custom, false).matches(false);
|
let results = Model::new(buffer, &alphabet, &named_pat, &custom, false).matches(false);
|
||||||
|
|
||||||
assert_eq!(results.len(), 3);
|
assert_eq!(results.len(), 3);
|
||||||
|
assert_eq!(results.get(0).unwrap().pattern, "ipv4");
|
||||||
assert_eq!(results.get(0).unwrap().text, "127.0.0.1");
|
assert_eq!(results.get(0).unwrap().text, "127.0.0.1");
|
||||||
|
assert_eq!(results.get(1).unwrap().pattern, "ipv4");
|
||||||
assert_eq!(results.get(1).unwrap().text, "255.255.10.255");
|
assert_eq!(results.get(1).unwrap().text, "255.255.10.255");
|
||||||
|
assert_eq!(results.get(2).unwrap().pattern, "ipv4");
|
||||||
assert_eq!(results.get(2).unwrap().text, "127.0.0.1");
|
assert_eq!(results.get(2).unwrap().text, "127.0.0.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@ use crate::error;
|
||||||
pub const EXCLUDE_PATTERNS: [(&'static str, &'static str); 1] =
|
pub const EXCLUDE_PATTERNS: [(&'static str, &'static str); 1] =
|
||||||
[("ansi_colors", r"[[:cntrl:]]\[([0-9]{1,2};)?([0-9]{1,2})?m")];
|
[("ansi_colors", r"[[:cntrl:]]\[([0-9]{1,2};)?([0-9]{1,2})?m")];
|
||||||
|
|
||||||
|
/// Holds all the regex patterns that are currently supported.
|
||||||
|
///
|
||||||
|
/// The email address was obtained at https://www.regular-expressions.info/email.html.
|
||||||
|
/// Others were obtained from Ferran Basora.
|
||||||
pub const PATTERNS: [(&'static str, &'static str); 15] = [
|
pub const PATTERNS: [(&'static str, &'static str); 15] = [
|
||||||
("markdown-url", r"\[[^]]*\]\(([^)]+)\)"),
|
("markdown-url", r"\[[^]]*\]\(([^)]+)\)"),
|
||||||
(
|
(
|
||||||
|
|
@ -21,7 +25,7 @@ pub const PATTERNS: [(&'static str, &'static str); 15] = [
|
||||||
),
|
),
|
||||||
("ipfs", r"Qm[0-9a-zA-Z]{44}"),
|
("ipfs", r"Qm[0-9a-zA-Z]{44}"),
|
||||||
("sha", r"[0-9a-f]{7,40}"),
|
("sha", r"[0-9a-f]{7,40}"),
|
||||||
("ip", r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"),
|
("ipv4", r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"),
|
||||||
("ipv6", r"[A-f0-9:]+:+[A-f0-9:]+[%\w\d]+"),
|
("ipv6", r"[A-f0-9:]+:+[A-f0-9:]+[%\w\d]+"),
|
||||||
("mem-address", r"0x[0-9a-fA-F]+"),
|
("mem-address", r"0x[0-9a-fA-F]+"),
|
||||||
("number", r"[0-9]{4,}"),
|
("number", r"[0-9]{4,}"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue