(matcher)
| 19376 | } |
| 19377 | |
| 19378 | function adjustMatcher(matcher) { |
| 19379 | if (matcher === 'self') { |
| 19380 | return matcher; |
| 19381 | } else if (isString(matcher)) { |
| 19382 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 19383 | // '*' matches any character except those from the set ':/.?&'. |
| 19384 | // '**' matches any character (like .* in a RegExp). |
| 19385 | // More than 2 *'s raises an error as it's ill defined. |
| 19386 | if (matcher.indexOf('***') > -1) { |
| 19387 | throw $sceMinErr('iwcard', |
| 19388 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 19389 | } |
| 19390 | matcher = escapeForRegexp(matcher). |
| 19391 | replace(/\\\*\\\*/g, '.*'). |
| 19392 | replace(/\\\*/g, '[^:/.?&;]*'); |
| 19393 | return new RegExp('^' + matcher + '$'); |
| 19394 | } else if (isRegExp(matcher)) { |
| 19395 | // The only other type of matcher allowed is a Regexp. |
| 19396 | // Match entire URL / disallow partial matches. |
| 19397 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 19398 | return new RegExp('^' + matcher.source + '$'); |
| 19399 | } else { |
| 19400 | throw $sceMinErr('imatcher', |
| 19401 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 19402 | } |
| 19403 | } |
| 19404 | |
| 19405 | |
| 19406 | function adjustMatchers(matchers) { |
no test coverage detected