Breaking: make exclusion rules work like match pattern
This commit is contained in:
parent
439386f090
commit
03b1c9abec
|
@ -43,7 +43,7 @@ const styleManager = (() => {
|
|||
const BAD_MATCHER = {test: () => false};
|
||||
const compileRe = createCompiler(text => `^(${text})$`);
|
||||
const compileSloppyRe = createCompiler(text => `^${text}$`);
|
||||
const compileExclusion = createCompiler(buildGlob);
|
||||
const compileExclusion = createCompiler(buildExclusion);
|
||||
|
||||
const DUMMY_URL = {
|
||||
hash: '',
|
||||
|
@ -544,8 +544,22 @@ const styleManager = (() => {
|
|||
};
|
||||
}
|
||||
|
||||
function buildGlob(text) {
|
||||
return '^' + escapeRegExp(text).replace(/\\\\\\\*|\\\*/g, m => m.length > 2 ? m : '.*') + '$';
|
||||
function compileGlob(text) {
|
||||
return escapeRegExp(text).replace(/\\\\\\\*|\\\*/g, m => m.length > 2 ? m : '.*');
|
||||
}
|
||||
|
||||
function buildExclusion(text) {
|
||||
// match pattern
|
||||
const match = text.match(/^(\*|[\w-]+):\/\/(\*\.)?([\w.]+\/.*)/);
|
||||
if (!match) {
|
||||
return '^' + compileGlob(text) + '$';
|
||||
}
|
||||
return '^' +
|
||||
(match[1] === '*' ? '[\\w-]+' : match[1]) +
|
||||
'://' +
|
||||
(match[2] ? '(?:[\\w.]+\\.)?' : '') +
|
||||
compileGlob(match[3]) +
|
||||
'$';
|
||||
}
|
||||
|
||||
// The md5Url provided by USO includes a duplicate "update" subdomain (see #523),
|
||||
|
|
Loading…
Reference in New Issue
Block a user