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

Function host_pattern_matches

crates/openshell-server/src/grpc/provider.rs:680–693  ·  view source on GitHub ↗
(pattern: &str, host: &str)

Source from the content-addressed store, hash-verified

678}
679
680fn host_pattern_matches(pattern: &str, host: &str) -> bool {
681 let pattern = pattern.to_ascii_lowercase();
682 let host = host.to_ascii_lowercase();
683 if pattern == host {
684 return true;
685 }
686 if !pattern.contains('*') {
687 return false;
688 }
689
690 let pattern_labels: Vec<&str> = pattern.split('.').collect();
691 let host_labels: Vec<&str> = host.split('.').collect();
692 host_pattern_labels_match(&pattern_labels, &host_labels)
693}
694
695fn host_pattern_labels_match(pattern: &[&str], host: &[&str]) -> bool {
696 match pattern.split_first() {

Calls 1

Tested by

no test coverage detected