(matcher)
| 19341 | } |
| 19342 | |
| 19343 | function adjustMatcher(matcher) { |
| 19344 | if (matcher === 'self') { |
| 19345 | return matcher; |
| 19346 | } else if (isString(matcher)) { |
| 19347 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 19348 | // '*' matches any character except those from the set ':/.?&'. |
| 19349 | // '**' matches any character (like .* in a RegExp). |
| 19350 | // More than 2 *'s raises an error as it's ill defined. |
| 19351 | if (matcher.indexOf('***') > -1) { |
| 19352 | throw $sceMinErr('iwcard', |
| 19353 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 19354 | } |
| 19355 | matcher = escapeForRegexp(matcher). |
| 19356 | replace(/\\\*\\\*/g, '.*'). |
| 19357 | replace(/\\\*/g, '[^:/.?&;]*'); |
| 19358 | return new RegExp('^' + matcher + '$'); |
| 19359 | } else if (isRegExp(matcher)) { |
| 19360 | // The only other type of matcher allowed is a Regexp. |
| 19361 | // Match entire URL / disallow partial matches. |
| 19362 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 19363 | return new RegExp('^' + matcher.source + '$'); |
| 19364 | } else { |
| 19365 | throw $sceMinErr('imatcher', |
| 19366 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 19367 | } |
| 19368 | } |
| 19369 | |
| 19370 | |
| 19371 | function adjustMatchers(matchers) { |
no test coverage detected