MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / adjustMatcher

Function adjustMatcher

code/songhop/www/lib/angular/angular.js:14838–14863  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

14836// Helper functions follow.
14837
14838function adjustMatcher(matcher) {
14839 if (matcher === 'self') {
14840 return matcher;
14841 } else if (isString(matcher)) {
14842 // Strings match exactly except for 2 wildcards - '*' and '**'.
14843 // '*' matches any character except those from the set ':/.?&'.
14844 // '**' matches any character (like .* in a RegExp).
14845 // More than 2 *'s raises an error as it's ill defined.
14846 if (matcher.indexOf('***') > -1) {
14847 throw $sceMinErr('iwcard',
14848 'Illegal sequence *** in string matcher. String: {0}', matcher);
14849 }
14850 matcher = escapeForRegexp(matcher).
14851 replace('\\*\\*', '.*').
14852 replace('\\*', '[^:/.?&;]*');
14853 return new RegExp('^' + matcher + '$');
14854 } else if (isRegExp(matcher)) {
14855 // The only other type of matcher allowed is a Regexp.
14856 // Match entire URL / disallow partial matches.
14857 // Flags are reset (i.e. no global, ignoreCase or multiline)
14858 return new RegExp('^' + matcher.source + '$');
14859 } else {
14860 throw $sceMinErr('imatcher',
14861 'Matchers may only be "self", string patterns or RegExp objects');
14862 }
14863}
14864
14865
14866function adjustMatchers(matchers) {

Callers 1

adjustMatchersFunction · 0.70

Calls 3

isStringFunction · 0.70
escapeForRegexpFunction · 0.70
isRegExpFunction · 0.70

Tested by

no test coverage detected