MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / adjustMatcher

Function adjustMatcher

lib/test/angular/1.5.0/angular.js:17341–17366  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

17339// Helper functions follow.
17340
17341function adjustMatcher(matcher) {
17342 if (matcher === 'self') {
17343 return matcher;
17344 } else if (isString(matcher)) {
17345 // Strings match exactly except for 2 wildcards - '*' and '**'.
17346 // '*' matches any character except those from the set ':/.?&'.
17347 // '**' matches any character (like .* in a RegExp).
17348 // More than 2 *'s raises an error as it's ill defined.
17349 if (matcher.indexOf('***') > -1) {
17350 throw $sceMinErr('iwcard',
17351 'Illegal sequence *** in string matcher. String: {0}', matcher);
17352 }
17353 matcher = escapeForRegexp(matcher).
17354 replace('\\*\\*', '.*').
17355 replace('\\*', '[^:/.?&;]*');
17356 return new RegExp('^' + matcher + '$');
17357 } else if (isRegExp(matcher)) {
17358 // The only other type of matcher allowed is a Regexp.
17359 // Match entire URL / disallow partial matches.
17360 // Flags are reset (i.e. no global, ignoreCase or multiline)
17361 return new RegExp('^' + matcher.source + '$');
17362 } else {
17363 throw $sceMinErr('imatcher',
17364 'Matchers may only be "self", string patterns or RegExp objects');
17365 }
17366}
17367
17368
17369function adjustMatchers(matchers) {

Callers 1

adjustMatchersFunction · 0.70

Calls 3

isStringFunction · 0.70
escapeForRegexpFunction · 0.70
isRegExpFunction · 0.70

Tested by

no test coverage detected