MCPcopy
hub / github.com/angular-ui/ui-router / adjustMatcher

Function adjustMatcher

test/angular/1.7/angular.js:19958–19983  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

19956}
19957
19958function adjustMatcher(matcher) {
19959 if (matcher === 'self') {
19960 return matcher;
19961 } else if (isString(matcher)) {
19962 // Strings match exactly except for 2 wildcards - '*' and '**'.
19963 // '*' matches any character except those from the set ':/.?&'.
19964 // '**' matches any character (like .* in a RegExp).
19965 // More than 2 *'s raises an error as it's ill defined.
19966 if (matcher.indexOf('***') > -1) {
19967 throw $sceMinErr('iwcard',
19968 'Illegal sequence *** in string matcher. String: {0}', matcher);
19969 }
19970 matcher = escapeForRegexp(matcher).
19971 replace(/\\\*\\\*/g, '.*').
19972 replace(/\\\*/g, '[^:/.?&;]*');
19973 return new RegExp('^' + matcher + '$');
19974 } else if (isRegExp(matcher)) {
19975 // The only other type of matcher allowed is a Regexp.
19976 // Match entire URL / disallow partial matches.
19977 // Flags are reset (i.e. no global, ignoreCase or multiline)
19978 return new RegExp('^' + matcher.source + '$');
19979 } else {
19980 throw $sceMinErr('imatcher',
19981 'Matchers may only be "self", string patterns or RegExp objects');
19982 }
19983}
19984
19985
19986function adjustMatchers(matchers) {

Callers 1

adjustMatchersFunction · 0.70

Calls 3

isStringFunction · 0.70
escapeForRegexpFunction · 0.70
isRegExpFunction · 0.70

Tested by

no test coverage detected