MCPcopy Create free account
hub / github.com/bclinkinbeard/angular / adjustMatcher

Function adjustMatcher

test/fixtures/foo.js:13111–13136  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

13109
13110
13111function 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
13139function adjustMatchers(matchers) {

Callers 1

adjustMatchersFunction · 0.85

Calls 3

isStringFunction · 0.85
escapeForRegexpFunction · 0.85
isRegExpFunction · 0.85

Tested by

no test coverage detected