tessl install tessl/npm-glob-to-regexp@0.4.0Convert globs to regular expressions
Agent Success
Agent success rate when using this tile
100%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.15x
Baseline
Agent success rate without this tile
87%
A utility that validates and filters URL paths based on configurable pattern matching rules.
@generates
Build a URL path validator that can check if URL paths match specific patterns. The validator needs to support two different matching modes: exact path matching and substring matching.
The validator must support two distinct matching behaviors:
Implement a validator that can:
Create a function createExactMatcher(pattern) that:
Examples:
Pattern "*.json" should match "config.json" but not "config.json.bak" or "data/config.json"
Pattern "api/*" should match "api/users" but not "v1/api/users" or "api/users/123"
It validates exact path matches using wildcards @test
Create a function createSubstringMatcher(pattern) that:
Examples:
Pattern "*.json" should match "config.json", "config.json.bak", and "data/config.json"
Pattern "api" should match "api/users", "v1/api/users", and "legacy-api"
It validates substring matches using wildcards @test
Create a function filterPaths(paths, pattern, mode) that:
Accepts an array of URL paths
Accepts a wildcard pattern
Accepts a mode parameter: "exact" or "substring"
Returns an array containing only paths that match according to the specified mode
It filters paths based on exact matching mode @test
It filters paths based on substring matching mode @test
/**
* Creates a matcher function for exact path matching
* @param {string} pattern - Wildcard pattern to match
* @returns {function(string): boolean} Matcher function
*/
function createExactMatcher(pattern) {
// Implementation
}
/**
* Creates a matcher function for substring matching
* @param {string} pattern - Wildcard pattern to match
* @returns {function(string): boolean} Matcher function
*/
function createSubstringMatcher(pattern) {
// Implementation
}
/**
* Filters paths based on pattern and matching mode
* @param {string[]} paths - Array of URL paths
* @param {string} pattern - Wildcard pattern to match
* @param {string} mode - Matching mode: "exact" or "substring"
* @returns {string[]} Filtered array of matching paths
*/
function filterPaths(paths, pattern, mode) {
// Implementation
}
module.exports = {
createExactMatcher,
createSubstringMatcher,
filterPaths
};Converts glob patterns to regular expressions for pattern matching.