MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / adjustMatcher

Function adjustMatcher

web/static/bower_components/angular/angular.js:16494–16519  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

16492// Helper functions follow.
16493
16494function adjustMatcher(matcher) {
16495 if (matcher === 'self') {
16496 return matcher;
16497 } else if (isString(matcher)) {
16498 // Strings match exactly except for 2 wildcards - '*' and '**'.
16499 // '*' matches any character except those from the set ':/.?&'.
16500 // '**' matches any character (like .* in a RegExp).
16501 // More than 2 *'s raises an error as it's ill defined.
16502 if (matcher.indexOf('***') > -1) {
16503 throw $sceMinErr('iwcard',
16504 'Illegal sequence *** in string matcher. String: {0}', matcher);
16505 }
16506 matcher = escapeForRegexp(matcher).
16507 replace('\\*\\*', '.*').
16508 replace('\\*', '[^:/.?&;]*');
16509 return new RegExp('^' + matcher + '$');
16510 } else if (isRegExp(matcher)) {
16511 // The only other type of matcher allowed is a Regexp.
16512 // Match entire URL / disallow partial matches.
16513 // Flags are reset (i.e. no global, ignoreCase or multiline)
16514 return new RegExp('^' + matcher.source + '$');
16515 } else {
16516 throw $sceMinErr('imatcher',
16517 'Matchers may only be "self", string patterns or RegExp objects');
16518 }
16519}
16520
16521
16522function adjustMatchers(matchers) {

Callers 1

adjustMatchersFunction · 0.85

Calls 3

isStringFunction · 0.85
escapeForRegexpFunction · 0.85
isRegExpFunction · 0.85

Tested by

no test coverage detected