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

Function host_pattern_specificity

crates/openshell-providers/src/profiles.rs:1503–1511  ·  view source on GitHub ↗
(pattern: &str)

Source from the content-addressed store, hash-verified

1501}
1502
1503fn host_pattern_specificity(pattern: &str) -> u32 {
1504 let wildcard_penalty = count_as_u32(pattern.matches('*').count());
1505 let label_count = count_as_u32(pattern.split('.').filter(|label| !label.is_empty()).count());
1506 let literal_chars = count_as_u32(pattern.chars().filter(|ch| *ch != '*').count());
1507 100_000u32
1508 .saturating_sub(wildcard_penalty.saturating_mul(10_000))
1509 .saturating_add(label_count.saturating_mul(100))
1510 .saturating_add(literal_chars)
1511}
1512
1513fn endpoint_path_specificity(path: &str) -> u32 {
1514 if path.is_empty() || path == "**" {

Callers 1

Calls 2

count_as_u32Function · 0.70
is_emptyMethod · 0.45

Tested by

no test coverage detected