MCPcopy Index your code
hub / github.com/zxlie/FeHelper / _matchesCurrentOriginPattern

Function _matchesCurrentOriginPattern

apps/json-format/content-script.js:244–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242 let _normalizeExcludedOriginPattern = value => String(value || '').trim().replace(/\/+$/, '').toLowerCase();
243
244 let _matchesCurrentOriginPattern = value => {
245 let origin = _getCurrentOriginPattern().toLowerCase();
246 let hostname = String(location.hostname || '').toLowerCase();
247 let pattern = _normalizeExcludedOriginPattern(value);
248
249 if (!pattern) {
250 return false;
251 }
252 if (pattern === '*') {
253 return true;
254 }
255 if (pattern === origin || (hostname && pattern === hostname)) {
256 return true;
257 }
258 if (pattern.indexOf('*.') === 0 && hostname) {
259 let suffix = pattern.slice(2);
260 return hostname === suffix || hostname.endsWith('.' + suffix);
261 }
262 return false;
263 };
264
265 let _isCurrentOriginExcluded = () => {
266 return _getExcludedOriginList(formatOptions.JSON_FORMAT_EXCLUDED_ORIGINS).some(_matchesCurrentOriginPattern);

Callers 1

Calls 2

_getCurrentOriginPatternFunction · 0.85

Tested by

no test coverage detected