MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / host_pattern_matches

Function host_pattern_matches

crates/openshell-providers/src/profiles.rs:1467–1480  ·  view source on GitHub ↗
(pattern: &str, host: &str)

Source from the content-addressed store, hash-verified

1465}
1466
1467fn host_pattern_matches(pattern: &str, host: &str) -> bool {
1468 let pattern = pattern.to_ascii_lowercase();
1469 let host = host.to_ascii_lowercase();
1470 if pattern == host {
1471 return true;
1472 }
1473 if !pattern.contains('*') {
1474 return false;
1475 }
1476
1477 let pattern_labels: Vec<&str> = pattern.split('.').collect();
1478 let host_labels: Vec<&str> = host.split('.').collect();
1479 host_pattern_labels_match(&pattern_labels, &host_labels)
1480}
1481
1482fn host_pattern_labels_match(pattern: &[&str], host: &[&str]) -> bool {
1483 match pattern.split_first() {

Calls 1

Tested by

no test coverage detected