···121 return result;
122}
123000000000000000124// Check if a request should be blocked based on host and path
125export function shouldBlock(host: string, path: string): boolean {
126 const config = getConfig();
···137 continue;
138 }
139140- // Check if any of the flag's paths match
141 for (const flagPath of flag.paths) {
142- if (path === flagPath || path.startsWith(flagPath + "/") || path.startsWith(flagPath + "?")) {
143 return true;
144 }
145 }
···121 return result;
122}
123124+// Match a path pattern against a request path (supports * wildcard for single segment)
125+function matchPath(pattern: string, path: string): boolean {
126+ if (!pattern.includes("*")) {
127+ return path === pattern || path.startsWith(pattern + "/") || path.startsWith(pattern + "?");
128+ }
129+130+ // Convert pattern to regex: * matches any single path segment
131+ const regexPattern = pattern
132+ .replace(/[.+^${}()|[\]\\]/g, "\\$&") // escape regex special chars except *
133+ .replace(/\*/g, "[^/]+"); // * matches one path segment
134+135+ const regex = new RegExp(`^${regexPattern}($|\\?|/)`);
136+ return regex.test(path);
137+}
138+139// Check if a request should be blocked based on host and path
140export function shouldBlock(host: string, path: string): boolean {
141 const config = getConfig();
···152 continue;
153 }
154155+ // Check if any of the flag's paths match (supports * wildcard)
156 for (const flagPath of flag.paths) {
157+ if (matchPath(flagPath, path)) {
158 return true;
159 }
160 }