(matcher)
| 13318 | |
| 13319 | |
| 13320 | function adjustMatcher(matcher) { |
| 13321 | if (matcher === 'self') { |
| 13322 | return matcher; |
| 13323 | } else if (isString(matcher)) { |
| 13324 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 13325 | // '*' matches any character except those from the set ':/.?&'. |
| 13326 | // '**' matches any character (like .* in a RegExp). |
| 13327 | // More than 2 *'s raises an error as it's ill defined. |
| 13328 | if (matcher.indexOf('***') > -1) { |
| 13329 | throw $sceMinErr('iwcard', |
| 13330 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 13331 | } |
| 13332 | matcher = escapeForRegexp(matcher). |
| 13333 | replace('\\*\\*', '.*'). |
| 13334 | replace('\\*', '[^:/.?&;]*'); |
| 13335 | return new RegExp('^' + matcher + '$'); |
| 13336 | } else if (isRegExp(matcher)) { |
| 13337 | // The only other type of matcher allowed is a Regexp. |
| 13338 | // Match entire URL / disallow partial matches. |
| 13339 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 13340 | return new RegExp('^' + matcher.source + '$'); |
| 13341 | } else { |
| 13342 | throw $sceMinErr('imatcher', |
| 13343 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 13344 | } |
| 13345 | } |
| 13346 | |
| 13347 | |
| 13348 | function adjustMatchers(matchers) { |
no test coverage detected