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

Function host_pattern_labels_match

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

Source from the content-addressed store, hash-verified

1480}
1481
1482fn host_pattern_labels_match(pattern: &[&str], host: &[&str]) -> bool {
1483 match pattern.split_first() {
1484 None => host.is_empty(),
1485 Some((label, rest)) if *label == "**" => {
1486 host_pattern_labels_match(rest, host)
1487 || (!host.is_empty() && host_pattern_labels_match(pattern, &host[1..]))
1488 }
1489 Some((label, rest)) if *label == "*" => {
1490 !host.is_empty() && host_pattern_labels_match(rest, &host[1..])
1491 }
1492 Some((literal, rest)) => {
1493 host.first().is_some_and(|label| label == literal)
1494 && host_pattern_labels_match(rest, &host[1..])
1495 }
1496 }
1497}
1498
1499fn dynamic_token_grant_match_score(host: &str, path: &str) -> u32 {
1500 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