(matcher)
| 16492 | // Helper functions follow. |
| 16493 | |
| 16494 | function adjustMatcher(matcher) { |
| 16495 | if (matcher === 'self') { |
| 16496 | return matcher; |
| 16497 | } else if (isString(matcher)) { |
| 16498 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 16499 | // '*' matches any character except those from the set ':/.?&'. |
| 16500 | // '**' matches any character (like .* in a RegExp). |
| 16501 | // More than 2 *'s raises an error as it's ill defined. |
| 16502 | if (matcher.indexOf('***') > -1) { |
| 16503 | throw $sceMinErr('iwcard', |
| 16504 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 16505 | } |
| 16506 | matcher = escapeForRegexp(matcher). |
| 16507 | replace('\\*\\*', '.*'). |
| 16508 | replace('\\*', '[^:/.?&;]*'); |
| 16509 | return new RegExp('^' + matcher + '$'); |
| 16510 | } else if (isRegExp(matcher)) { |
| 16511 | // The only other type of matcher allowed is a Regexp. |
| 16512 | // Match entire URL / disallow partial matches. |
| 16513 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 16514 | return new RegExp('^' + matcher.source + '$'); |
| 16515 | } else { |
| 16516 | throw $sceMinErr('imatcher', |
| 16517 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 16518 | } |
| 16519 | } |
| 16520 | |
| 16521 | |
| 16522 | function adjustMatchers(matchers) { |
no test coverage detected