(matcher)
| 20021 | } |
| 20022 | |
| 20023 | function adjustMatcher(matcher) { |
| 20024 | if (matcher === 'self') { |
| 20025 | return matcher; |
| 20026 | } else if (isString(matcher)) { |
| 20027 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 20028 | // '*' matches any character except those from the set ':/.?&'. |
| 20029 | // '**' matches any character (like .* in a RegExp). |
| 20030 | // More than 2 *'s raises an error as it's ill defined. |
| 20031 | if (matcher.indexOf('***') > -1) { |
| 20032 | throw $sceMinErr('iwcard', |
| 20033 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 20034 | } |
| 20035 | matcher = escapeForRegexp(matcher). |
| 20036 | replace(/\\\*\\\*/g, '.*'). |
| 20037 | replace(/\\\*/g, '[^:/.?&;]*'); |
| 20038 | return new RegExp('^' + matcher + '$'); |
| 20039 | } else if (isRegExp(matcher)) { |
| 20040 | // The only other type of matcher allowed is a Regexp. |
| 20041 | // Match entire URL / disallow partial matches. |
| 20042 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 20043 | return new RegExp('^' + matcher.source + '$'); |
| 20044 | } else { |
| 20045 | throw $sceMinErr('imatcher', |
| 20046 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 20047 | } |
| 20048 | } |
| 20049 | |
| 20050 | |
| 20051 | function adjustMatchers(matchers) { |
no test coverage detected