* The inside of a matcher's group: `.*`, `.+`, `a|b` of literals, or * `(?!a|b|….*\.png$).*`, the form almost every real matcher takes.
(body: string)
| 240 | * `(?!a|b|….*\.png$).*`, the form almost every real matcher takes. |
| 241 | */ |
| 242 | function readGroup(body: string): string | null { |
| 243 | if (body === '.*' || body === '.+') return body; |
| 244 | if (body.startsWith('(?!')) { |
| 245 | const close = closingParen(body, 0); |
| 246 | const tail = close < 0 ? '' : body.slice(close + 1); |
| 247 | if (tail !== '.*' && tail !== '.+') return null; |
| 248 | const branches = topLevelBars(body.slice(3, close)).map(readExclusion); |
| 249 | return branches.includes(null) ? null : `(?!${[...new Set(branches)].join('|')})${tail}`; |
| 250 | } |
| 251 | const options = topLevelBars(body.replace(/^\?:/, '')); |
| 252 | if (!options.every((option) => /^[\w./~-]+$/.test(option))) return null; |
| 253 | return `(?:${options.map(escapeRegex).join('|')})`; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * A matcher entry as a regular expression, or null for one this doesn't read, |
no test coverage detected