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

Function path_patterns_can_overlap

crates/openshell-server/src/grpc/provider.rs:776–794  ·  view source on GitHub ↗
(first: &str, second: &str)

Source from the content-addressed store, hash-verified

774}
775
776fn path_patterns_can_overlap(first: &str, second: &str) -> bool {
777 if path_matches_all(first) || path_matches_all(second) {
778 return true;
779 }
780 if !first.contains('*') {
781 return endpoint_path_matches(second, first);
782 }
783 if !second.contains('*') {
784 return endpoint_path_matches(first, second);
785 }
786 match (path_prefix_pattern(first), path_prefix_pattern(second)) {
787 (Some(first_prefix), Some(second_prefix)) => {
788 first_prefix == second_prefix
789 || first_prefix.starts_with(&format!("{second_prefix}/"))
790 || second_prefix.starts_with(&format!("{first_prefix}/"))
791 }
792 _ => true,
793 }
794}
795
796fn path_matches_all(path: &str) -> bool {
797 path.is_empty() || path == "**" || path == "/**"

Calls 3

path_matches_allFunction · 0.70
endpoint_path_matchesFunction · 0.70
path_prefix_patternFunction · 0.70

Tested by

no test coverage detected