MCPcopy Index your code
hub / github.com/angular-ui/ui-router / adjustMatcher

Function adjustMatcher

test/angular/1.3/angular.js:15067–15092  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

15065// Helper functions follow.
15066
15067function adjustMatcher(matcher) {
15068 if (matcher === 'self') {
15069 return matcher;
15070 } else if (isString(matcher)) {
15071 // Strings match exactly except for 2 wildcards - '*' and '**'.
15072 // '*' matches any character except those from the set ':/.?&'.
15073 // '**' matches any character (like .* in a RegExp).
15074 // More than 2 *'s raises an error as it's ill defined.
15075 if (matcher.indexOf('***') > -1) {
15076 throw $sceMinErr('iwcard',
15077 'Illegal sequence *** in string matcher. String: {0}', matcher);
15078 }
15079 matcher = escapeForRegexp(matcher).
15080 replace('\\*\\*', '.*').
15081 replace('\\*', '[^:/.?&;]*');
15082 return new RegExp('^' + matcher + '$');
15083 } else if (isRegExp(matcher)) {
15084 // The only other type of matcher allowed is a Regexp.
15085 // Match entire URL / disallow partial matches.
15086 // Flags are reset (i.e. no global, ignoreCase or multiline)
15087 return new RegExp('^' + matcher.source + '$');
15088 } else {
15089 throw $sceMinErr('imatcher',
15090 'Matchers may only be "self", string patterns or RegExp objects');
15091 }
15092}
15093
15094
15095function adjustMatchers(matchers) {

Callers 1

adjustMatchersFunction · 0.70

Calls 3

isStringFunction · 0.70
escapeForRegexpFunction · 0.70
isRegExpFunction · 0.70

Tested by

no test coverage detected