MCPcopy Create free account
hub / github.com/OpenReservation/OpenReservation / adjustMatcher

Function adjustMatcher

OpenReservation/wwwroot/Scripts/angular.js:17816–17840  ·  view source on GitHub ↗
(matcher)

Source from the content-addressed store, hash-verified

17814 // Helper functions follow.
17815
17816 function adjustMatcher(matcher) {
17817 if (matcher === 'self') {
17818 return matcher;
17819 } else if (isString(matcher)) {
17820 // Strings match exactly except for 2 wildcards - '*' and '**'.
17821 // '*' matches any character except those from the set ':/.?&'.
17822 // '**' matches any character (like .* in a RegExp).
17823 // More than 2 *'s raises an error as it's ill defined.
17824 if (matcher.indexOf('***') > -1) {
17825 throw $sceMinErr('iwcard',
17826 'Illegal sequence *** in string matcher. String: {0}',
17827 matcher);
17828 }
17829 matcher = escapeForRegexp(matcher).replace('\\*\\*', '.*').replace('\\*', '[^:/.?&;]*');
17830 return new RegExp('^' + matcher + '$');
17831 } else if (isRegExp(matcher)) {
17832 // The only other type of matcher allowed is a Regexp.
17833 // Match entire URL / disallow partial matches.
17834 // Flags are reset (i.e. no global, ignoreCase or multiline)
17835 return new RegExp('^' + matcher.source + '$');
17836 } else {
17837 throw $sceMinErr('imatcher',
17838 'Matchers may only be "self", string patterns or RegExp objects');
17839 }
17840 }
17841
17842 function adjustMatchers(matchers) {
17843 var adjustedMatchers = [];

Callers 1

adjustMatchersFunction · 0.85

Calls 3

isStringFunction · 0.85
escapeForRegexpFunction · 0.85
isRegExpFunction · 0.85

Tested by

no test coverage detected