@opra/common
Version:
Opra common package
13 lines (12 loc) • 386 B
JavaScript
export function testScopeMatch(scope, pattern) {
if (!pattern || scope === '*')
return true;
if (!scope)
return false;
if (Array.isArray(pattern)) {
return pattern.some(x => {
return typeof x === 'string' ? scope === x : x.test(scope);
});
}
return typeof pattern === 'string' ? scope === pattern : pattern.test(scope);
}