(patterns: ReadonlySet<string>)
| 278 | }; |
| 279 | |
| 280 | const createReGroup = (patterns: ReadonlySet<string>): string => { |
| 281 | switch (patterns.size) { |
| 282 | case 0: |
| 283 | return ''; |
| 284 | case 1: |
| 285 | return patterns.values().next().value; |
| 286 | default: |
| 287 | // Prefer the more compacy [aA] form if we're only matching single |
| 288 | // characters, produce a non-capturing group otherwise. |
| 289 | const arr = [...patterns]; |
| 290 | return arr.some(p => p.length > 1) ? `(?:${arr.join('|')})` : `[${arr.join('')}]`; |
| 291 | } |
| 292 | }; |
| 293 | |
| 294 | /** |
| 295 | * Converts and escape the file URL to a regular expression. |
no test coverage detected