Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 115x 4x 4x 108x 108x 106x 106x 106x 106x 106x | export function removeTrailingSlashesAndMultiSlashes(str: string): string {
return str.replace(/\/+$/, '').replace(/(?<=\/)\/+/, '')
}
export function addTrailingWildcard(str: string): string {
return str.replace(/(\/?)\*/g, '($1.*)?')
}
export function replaceDot(str: string): string {
return str.replace(/\.(?=[\w(])/, '\\.')
}
export function addPathnameMatchBeforeRoute(route: string): string {
return `[\\/[A-Za-z0-9:._-]*${route}`
}
export function addEndingTrailingSlashToRoute(route: string): string {
return `${route}\\/*`
}
export function createRoute(route: string): RegExp {
let routeRegExp = route
// routeRegExp = addTrailingWildcard(routeRegExp) // Can be uncommented if wildcard (*) is needed
routeRegExp = removeTrailingSlashesAndMultiSlashes(routeRegExp)
routeRegExp = addPathnameMatchBeforeRoute(routeRegExp)
routeRegExp = addEndingTrailingSlashToRoute(routeRegExp)
// routeRegExp = replaceDot(routeRegExp) // Can be uncommented if dot (.) is needed
return RegExp(`^${routeRegExp}$`)
}
|