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

Function adjustMatcher

test/angular/1.4/angular.js:16905–16930  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

16903// Helper functions follow.
16904
16905function adjustMatcher(matcher) {
16906 if (matcher === 'self') {
16907 return matcher;
16908 } else if (isString(matcher)) {
16909 // Strings match exactly except for 2 wildcards - '*' and '**'.
16910 // '*' matches any character except those from the set ':/.?&'.
16911 // '**' matches any character (like .* in a RegExp).
16912 // More than 2 *'s raises an error as it's ill defined.
16913 if (matcher.indexOf('***') > -1) {
16914 throw $sceMinErr('iwcard',
16915 'Illegal sequence *** in string matcher. String: {0}', matcher);
16916 }
16917 matcher = escapeForRegexp(matcher).
16918 replace('\\*\\*', '.*').
16919 replace('\\*', '[^:/.?&;]*');
16920 return new RegExp('^' + matcher + '$');
16921 } else if (isRegExp(matcher)) {
16922 // The only other type of matcher allowed is a Regexp.
16923 // Match entire URL / disallow partial matches.
16924 // Flags are reset (i.e. no global, ignoreCase or multiline)
16925 return new RegExp('^' + matcher.source + '$');
16926 } else {
16927 throw $sceMinErr('imatcher',
16928 'Matchers may only be "self", string patterns or RegExp objects');
16929 }
16930}
16931
16932
16933function adjustMatchers(matchers) {

Callers 1

adjustMatchersFunction · 0.70

Calls 3

isStringFunction · 0.70
escapeForRegexpFunction · 0.70
isRegExpFunction · 0.70

Tested by

no test coverage detected