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

Function adjustMatcher

test/angular/1.2/angular.js:13320–13345  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

13318
13319
13320function adjustMatcher(matcher) {
13321 if (matcher === 'self') {
13322 return matcher;
13323 } else if (isString(matcher)) {
13324 // Strings match exactly except for 2 wildcards - '*' and '**'.
13325 // '*' matches any character except those from the set ':/.?&'.
13326 // '**' matches any character (like .* in a RegExp).
13327 // More than 2 *'s raises an error as it's ill defined.
13328 if (matcher.indexOf('***') > -1) {
13329 throw $sceMinErr('iwcard',
13330 'Illegal sequence *** in string matcher. String: {0}', matcher);
13331 }
13332 matcher = escapeForRegexp(matcher).
13333 replace('\\*\\*', '.*').
13334 replace('\\*', '[^:/.?&;]*');
13335 return new RegExp('^' + matcher + '$');
13336 } else if (isRegExp(matcher)) {
13337 // The only other type of matcher allowed is a Regexp.
13338 // Match entire URL / disallow partial matches.
13339 // Flags are reset (i.e. no global, ignoreCase or multiline)
13340 return new RegExp('^' + matcher.source + '$');
13341 } else {
13342 throw $sceMinErr('imatcher',
13343 'Matchers may only be "self", string patterns or RegExp objects');
13344 }
13345}
13346
13347
13348function adjustMatchers(matchers) {

Callers 1

adjustMatchersFunction · 0.70

Calls 3

isStringFunction · 0.70
escapeForRegexpFunction · 0.70
isRegExpFunction · 0.70

Tested by

no test coverage detected