(matcher)
| 14836 | // Helper functions follow. |
| 14837 | |
| 14838 | function adjustMatcher(matcher) { |
| 14839 | if (matcher === 'self') { |
| 14840 | return matcher; |
| 14841 | } else if (isString(matcher)) { |
| 14842 | // Strings match exactly except for 2 wildcards - '*' and '**'. |
| 14843 | // '*' matches any character except those from the set ':/.?&'. |
| 14844 | // '**' matches any character (like .* in a RegExp). |
| 14845 | // More than 2 *'s raises an error as it's ill defined. |
| 14846 | if (matcher.indexOf('***') > -1) { |
| 14847 | throw $sceMinErr('iwcard', |
| 14848 | 'Illegal sequence *** in string matcher. String: {0}', matcher); |
| 14849 | } |
| 14850 | matcher = escapeForRegexp(matcher). |
| 14851 | replace('\\*\\*', '.*'). |
| 14852 | replace('\\*', '[^:/.?&;]*'); |
| 14853 | return new RegExp('^' + matcher + '$'); |
| 14854 | } else if (isRegExp(matcher)) { |
| 14855 | // The only other type of matcher allowed is a Regexp. |
| 14856 | // Match entire URL / disallow partial matches. |
| 14857 | // Flags are reset (i.e. no global, ignoreCase or multiline) |
| 14858 | return new RegExp('^' + matcher.source + '$'); |
| 14859 | } else { |
| 14860 | throw $sceMinErr('imatcher', |
| 14861 | 'Matchers may only be "self", string patterns or RegExp objects'); |
| 14862 | } |
| 14863 | } |
| 14864 | |
| 14865 | |
| 14866 | function adjustMatchers(matchers) { |
no test coverage detected