(matcher)
| 19065 | } |
| 19066 | |
| 19067 | function adjustMatcher(matcher) { |
| 19068 | if (matcher === 'self') { |
| 19069 | return matcher; |
| 19070 | } else if (isString(matcher)) { |
| 19071 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 19072 | // '*' matches any character except those from the set ':/.?&'. |
| 19073 | // '**' matches any character (like .* in a RegExp). |
| 19074 | // More than 2 *'s raises an error as it's ill defined. |
| 19075 | if (matcher.indexOf('***') > -1) { |
| 19076 | throw $sceMinErr('iwcard', |
| 19077 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 19078 | } |
| 19079 | matcher = escapeForRegexp(matcher). |
| 19080 | replace(/\\\*\\\*/g, '.*'). |
| 19081 | replace(/\\\*/g, '[^:/.?&;]*'); |
| 19082 | return new RegExp('^' + matcher + '$'); |
| 19083 | } else if (isRegExp(matcher)) { |
| 19084 | // The only other type of matcher allowed is a Regexp. |
| 19085 | // Match entire URL / disallow partial matches. |
| 19086 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 19087 | return new RegExp('^' + matcher.source + '$'); |
| 19088 | } else { |
| 19089 | throw $sceMinErr('imatcher', |
| 19090 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 19091 | } |
| 19092 | } |
| 19093 | |
| 19094 | |
| 19095 | function adjustMatchers(matchers) { |
no test coverage detected