MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / wildcard_match

Function wildcard_match

crates/opencode-permission/src/ruleset.rs:128–149  ·  view source on GitHub ↗
(text: &str, pattern: &str)

Source from the content-addressed store, hash-verified

126}
127
128fn wildcard_match(text: &str, pattern: &str) -> bool {
129 if pattern == "*" {
130 return true;
131 }
132
133 if pattern.starts_with('*') && pattern.ends_with('*') {
134 let middle = &pattern[1..pattern.len() - 1];
135 return text.contains(middle);
136 }
137
138 if pattern.starts_with('*') {
139 let suffix = &pattern[1..];
140 return text.ends_with(suffix);
141 }
142
143 if pattern.ends_with('*') {
144 let prefix = &pattern[..pattern.len() - 1];
145 return text.starts_with(prefix);
146 }
147
148 text == pattern
149}
150
151pub fn default_ruleset() -> PermissionRuleset {
152 let mut rules = Vec::new();

Callers 2

evaluateFunction · 0.70
disabledFunction · 0.70

Calls 1

containsMethod · 0.80

Tested by

no test coverage detected