(file: string)
| 108 | } |
| 109 | |
| 110 | function compilePattern(file: string): RegExp { |
| 111 | let pattern = "^"; |
| 112 | let i = 0; |
| 113 | for (let match: RegExpExecArray | null, re = /\[([a-z_]\w*)\]/gi; (match = re.exec(file)); i = re.lastIndex) { |
| 114 | pattern += `${requote(file.slice(i, match.index))}(?<${match[1]}>.+)`; |
| 115 | } |
| 116 | pattern += `${requote(file.slice(i))}$`; |
| 117 | return new RegExp(pattern, "i"); |
| 118 | } |
| 119 | |
| 120 | export function requote(text: string): string { |
| 121 | return text.replace(/[\\^$*+?|[\]().{}]/g, "\\$&"); |
no test coverage detected