(matcher)
| 13109 | |
| 13110 | |
| 13111 | function adjustMatcher(matcher) { |
| 13112 | if (matcher === 'self') { |
| 13113 | return matcher; |
| 13114 | } else if (isString(matcher)) { |
| 13115 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 13116 | // '*' matches any character except those from the set ':/.?&'. |
| 13117 | // '**' matches any character (like .* in a RegExp). |
| 13118 | // More than 2 *'s raises an error as it's ill defined. |
| 13119 | if (matcher.indexOf('***') > -1) { |
| 13120 | throw $sceMinErr('iwcard', |
| 13121 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 13122 | } |
| 13123 | matcher = escapeForRegexp(matcher). |
| 13124 | replace('\\*\\*', '.*'). |
| 13125 | replace('\\*', '[^:/.?&;]*'); |
| 13126 | return new RegExp('^' + matcher + '$'); |
| 13127 | } else if (isRegExp(matcher)) { |
| 13128 | // The only other type of matcher allowed is a Regexp. |
| 13129 | // Match entire URL / disallow partial matches. |
| 13130 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 13131 | return new RegExp('^' + matcher.source + '$'); |
| 13132 | } else { |
| 13133 | throw $sceMinErr('imatcher', |
| 13134 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 13135 | } |
| 13136 | } |
| 13137 | |
| 13138 | |
| 13139 | function adjustMatchers(matchers) { |
no test coverage detected