Crates.io | match-domain |
lib.rs | match-domain |
version | 0.1.2 |
source | src |
created_at | 2024-11-21 08:55:18.52366 |
updated_at | 2024-11-22 06:59:49.300216 |
description | Rapid checker for the prefix and suffix matching of domain names |
homepage | https://github.com/junkurihara/rust-match-domain |
repository | https://github.com/junkurihara/rust-match-domain |
max_upload_size | |
id | 1455930 |
size | 12,461 |
match-domain
: Rapid checker for the prefix and suffix matching of domain names, written in RustDouble-array trie based domain matcher, written in Rust.
This enables you to check if the given domain name matches the prefix or suffix of the domain name in the trie.
use match_domain::DomainMatchingRule;
let domain_matching_rule = DomainMatchingRule::try_from(vec![
"www.google.com".to_string(),
"*.google.com".to_string(),
"yahoo.co.*".to_string(),
])
.unwrap();
assert!(domain_matching_rule.is_matched("wwxx.google.com"));
assert!(domain_matching_rule.is_matched("yahoo.co.jp"));
assert!(!domain_matching_rule.is_matched("www.yahoo.com"));
assert!(!domain_matching_rule.is_matched("www.yahoo.co.jp"));
Note that for the DomainMatchingRule::is_matched(&self, domain_name: &str) -> bool
method:
domain_name
should be in lowercasedomain_name
should not contain a leading dot