(matcher)
| 19956 | } |
| 19957 | |
| 19958 | function adjustMatcher(matcher) { |
| 19959 | if (matcher === 'self') { |
| 19960 | return matcher; |
| 19961 | } else if (isString(matcher)) { |
| 19962 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 19963 | // '*' matches any character except those from the set ':/.?&'. |
| 19964 | // '**' matches any character (like .* in a RegExp). |
| 19965 | // More than 2 *'s raises an error as it's ill defined. |
| 19966 | if (matcher.indexOf('***') > -1) { |
| 19967 | throw $sceMinErr('iwcard', |
| 19968 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 19969 | } |
| 19970 | matcher = escapeForRegexp(matcher). |
| 19971 | replace(/\\\*\\\*/g, '.*'). |
| 19972 | replace(/\\\*/g, '[^:/.?&;]*'); |
| 19973 | return new RegExp('^' + matcher + '$'); |
| 19974 | } else if (isRegExp(matcher)) { |
| 19975 | // The only other type of matcher allowed is a Regexp. |
| 19976 | // Match entire URL / disallow partial matches. |
| 19977 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 19978 | return new RegExp('^' + matcher.source + '$'); |
| 19979 | } else { |
| 19980 | throw $sceMinErr('imatcher', |
| 19981 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 19982 | } |
| 19983 | } |
| 19984 | |
| 19985 | |
| 19986 | function adjustMatchers(matchers) { |
no test coverage detected