(matcher)
| 16903 | // Helper functions follow. |
| 16904 | |
| 16905 | function adjustMatcher(matcher) { |
| 16906 | if (matcher === 'self') { |
| 16907 | return matcher; |
| 16908 | } else if (isString(matcher)) { |
| 16909 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 16910 | // '*' matches any character except those from the set ':/.?&'. |
| 16911 | // '**' matches any character (like .* in a RegExp). |
| 16912 | // More than 2 *'s raises an error as it's ill defined. |
| 16913 | if (matcher.indexOf('***') > -1) { |
| 16914 | throw $sceMinErr('iwcard', |
| 16915 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 16916 | } |
| 16917 | matcher = escapeForRegexp(matcher). |
| 16918 | replace('\\*\\*', '.*'). |
| 16919 | replace('\\*', '[^:/.?&;]*'); |
| 16920 | return new RegExp('^' + matcher + '$'); |
| 16921 | } else if (isRegExp(matcher)) { |
| 16922 | // The only other type of matcher allowed is a Regexp. |
| 16923 | // Match entire URL / disallow partial matches. |
| 16924 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 16925 | return new RegExp('^' + matcher.source + '$'); |
| 16926 | } else { |
| 16927 | throw $sceMinErr('imatcher', |
| 16928 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 16929 | } |
| 16930 | } |
| 16931 | |
| 16932 | |
| 16933 | function adjustMatchers(matchers) { |
no test coverage detected