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

Function adjustMatcher

lib/test/angular/1.7.0/angular.js:19378–19403  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

19376}
19377
19378function adjustMatcher(matcher) {
19379 if (matcher === 'self') {
19380 return matcher;
19381 } else if (isString(matcher)) {
19382 // Strings match exactly except for 2 wildcards - '*' and '**'.
19383 // '*' matches any character except those from the set ':/.?&'.
19384 // '**' matches any character (like .* in a RegExp).
19385 // More than 2 *'s raises an error as it's ill defined.
19386 if (matcher.indexOf('***') > -1) {
19387 throw $sceMinErr('iwcard',
19388 'Illegal sequence *** in string matcher. String: {0}', matcher);
19389 }
19390 matcher = escapeForRegexp(matcher).
19391 replace(/\\\*\\\*/g, '.*').
19392 replace(/\\\*/g, '[^:/.?&;]*');
19393 return new RegExp('^' + matcher + '$');
19394 } else if (isRegExp(matcher)) {
19395 // The only other type of matcher allowed is a Regexp.
19396 // Match entire URL / disallow partial matches.
19397 // Flags are reset (i.e. no global, ignoreCase or multiline)
19398 return new RegExp('^' + matcher.source + '$');
19399 } else {
19400 throw $sceMinErr('imatcher',
19401 'Matchers may only be "self", string patterns or RegExp objects');
19402 }
19403}
19404
19405
19406function adjustMatchers(matchers) {

Callers 1

adjustMatchersFunction · 0.70

Calls 3

isStringFunction · 0.70
escapeForRegexpFunction · 0.70
isRegExpFunction · 0.70

Tested by

no test coverage detected