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

Function adjustMatcher

lib/test/angular/1.8.0/angular.js:20023–20048  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

20021}
20022
20023function adjustMatcher(matcher) {
20024 if (matcher === 'self') {
20025 return matcher;
20026 } else if (isString(matcher)) {
20027 // Strings match exactly except for 2 wildcards - '*' and '**'.
20028 // '*' matches any character except those from the set ':/.?&'.
20029 // '**' matches any character (like .* in a RegExp).
20030 // More than 2 *'s raises an error as it's ill defined.
20031 if (matcher.indexOf('***') > -1) {
20032 throw $sceMinErr('iwcard',
20033 'Illegal sequence *** in string matcher. String: {0}', matcher);
20034 }
20035 matcher = escapeForRegexp(matcher).
20036 replace(/\\\*\\\*/g, '.*').
20037 replace(/\\\*/g, '[^:/.?&;]*');
20038 return new RegExp('^' + matcher + '$');
20039 } else if (isRegExp(matcher)) {
20040 // The only other type of matcher allowed is a Regexp.
20041 // Match entire URL / disallow partial matches.
20042 // Flags are reset (i.e. no global, ignoreCase or multiline)
20043 return new RegExp('^' + matcher.source + '$');
20044 } else {
20045 throw $sceMinErr('imatcher',
20046 'Matchers may only be "self", string patterns or RegExp objects');
20047 }
20048}
20049
20050
20051function adjustMatchers(matchers) {

Callers 1

adjustMatchersFunction · 0.70

Calls 3

isStringFunction · 0.70
escapeForRegexpFunction · 0.70
isRegExpFunction · 0.70

Tested by

no test coverage detected