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

Function host_pattern_specificity

crates/openshell-server/src/grpc/provider.rs:716–724  ·  view source on GitHub ↗
(pattern: &str)

Source from the content-addressed store, hash-verified

714}
715
716fn host_pattern_specificity(pattern: &str) -> u32 {
717 let wildcard_penalty = count_as_u32(pattern.matches('*').count());
718 let label_count = count_as_u32(pattern.split('.').filter(|label| !label.is_empty()).count());
719 let literal_chars = count_as_u32(pattern.chars().filter(|ch| *ch != '*').count());
720 100_000u32
721 .saturating_sub(wildcard_penalty.saturating_mul(10_000))
722 .saturating_add(label_count.saturating_mul(100))
723 .saturating_add(literal_chars)
724}
725
726fn endpoint_path_specificity(path: &str) -> u32 {
727 if path.is_empty() || path == "**" {

Callers 1

Calls 2

count_as_u32Function · 0.70
is_emptyMethod · 0.45

Tested by

no test coverage detected