(matcher)
| 16346 | // Helper functions follow. |
| 16347 | |
| 16348 | function adjustMatcher(matcher) { |
| 16349 | if (matcher === 'self') { |
| 16350 | return matcher; |
| 16351 | } else if (isString(matcher)) { |
| 16352 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 16353 | // '*' matches any character except those from the set ':/.?&'. |
| 16354 | // '**' matches any character (like .* in a RegExp). |
| 16355 | // More than 2 *'s raises an error as it's ill defined. |
| 16356 | if (matcher.indexOf('***') > -1) { |
| 16357 | throw $sceMinErr('iwcard', |
| 16358 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 16359 | } |
| 16360 | matcher = escapeForRegexp(matcher). |
| 16361 | replace('\\*\\*', '.*'). |
| 16362 | replace('\\*', '[^:/.?&;]*'); |
| 16363 | return new RegExp('^' + matcher + '$'); |
| 16364 | } else if (isRegExp(matcher)) { |
| 16365 | // The only other type of matcher allowed is a Regexp. |
| 16366 | // Match entire URL / disallow partial matches. |
| 16367 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 16368 | return new RegExp('^' + matcher.source + '$'); |
| 16369 | } else { |
| 16370 | throw $sceMinErr('imatcher', |
| 16371 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 16372 | } |
| 16373 | } |
| 16374 | |
| 16375 | |
| 16376 | function adjustMatchers(matchers) { |
no test coverage detected