(matcher)
| 18521 | // Helper functions follow. |
| 18522 | |
| 18523 | function adjustMatcher(matcher) { |
| 18524 | if (matcher === 'self') { |
| 18525 | return matcher; |
| 18526 | } else if (isString(matcher)) { |
| 18527 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 18528 | // '*' matches any character except those from the set ':/.?&'. |
| 18529 | // '**' matches any character (like .* in a RegExp). |
| 18530 | // More than 2 *'s raises an error as it's ill defined. |
| 18531 | if (matcher.indexOf('***') > -1) { |
| 18532 | throw $sceMinErr('iwcard', |
| 18533 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 18534 | } |
| 18535 | matcher = escapeForRegexp(matcher). |
| 18536 | replace(/\\\*\\\*/g, '.*'). |
| 18537 | replace(/\\\*/g, '[^:/.?&;]*'); |
| 18538 | return new RegExp('^' + matcher + '$'); |
| 18539 | } else if (isRegExp(matcher)) { |
| 18540 | // The only other type of matcher allowed is a Regexp. |
| 18541 | // Match entire URL / disallow partial matches. |
| 18542 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 18543 | return new RegExp('^' + matcher.source + '$'); |
| 18544 | } else { |
| 18545 | throw $sceMinErr('imatcher', |
| 18546 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 18547 | } |
| 18548 | } |
| 18549 | |
| 18550 | |
| 18551 | function adjustMatchers(matchers) { |
no test coverage detected