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

Function host_pattern_labels_match

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

Source from the content-addressed store, hash-verified

693}
694
695fn host_pattern_labels_match(pattern: &[&str], host: &[&str]) -> bool {
696 match pattern.split_first() {
697 None => host.is_empty(),
698 Some((label, rest)) if *label == "**" => {
699 host_pattern_labels_match(rest, host)
700 || (!host.is_empty() && host_pattern_labels_match(pattern, &host[1..]))
701 }
702 Some((label, rest)) if *label == "*" => {
703 !host.is_empty() && host_pattern_labels_match(rest, &host[1..])
704 }
705 Some((literal, rest)) => {
706 host.first().is_some_and(|label| label == literal)
707 && host_pattern_labels_match(rest, &host[1..])
708 }
709 }
710}
711
712fn dynamic_token_grant_match_score(host: &str, path: &str) -> u32 {
713 host_pattern_specificity(host) + endpoint_path_specificity(path)

Callers 1

host_pattern_matchesFunction · 0.70

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected