(matcher)
| 17339 | // Helper functions follow. |
| 17340 | |
| 17341 | function adjustMatcher(matcher) { |
| 17342 | if (matcher === 'self') { |
| 17343 | return matcher; |
| 17344 | } else if (isString(matcher)) { |
| 17345 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 17346 | // '*' matches any character except those from the set ':/.?&'. |
| 17347 | // '**' matches any character (like .* in a RegExp). |
| 17348 | // More than 2 *'s raises an error as it's ill defined. |
| 17349 | if (matcher.indexOf('***') > -1) { |
| 17350 | throw $sceMinErr('iwcard', |
| 17351 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 17352 | } |
| 17353 | matcher = escapeForRegexp(matcher). |
| 17354 | replace('\\*\\*', '.*'). |
| 17355 | replace('\\*', '[^:/.?&;]*'); |
| 17356 | return new RegExp('^' + matcher + '$'); |
| 17357 | } else if (isRegExp(matcher)) { |
| 17358 | // The only other type of matcher allowed is a Regexp. |
| 17359 | // Match entire URL / disallow partial matches. |
| 17360 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 17361 | return new RegExp('^' + matcher.source + '$'); |
| 17362 | } else { |
| 17363 | throw $sceMinErr('imatcher', |
| 17364 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 17365 | } |
| 17366 | } |
| 17367 | |
| 17368 | |
| 17369 | function adjustMatchers(matchers) { |
no test coverage detected