mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Code review for recent commit re path support in target
Related commit:
8b696a691a
1) There will always be a `/` at that point in the code path
2) The hostname will already be a match in that code path
This commit is contained in:
parent
c38101cd34
commit
f6f7333b5d
1 changed files with 10 additions and 17 deletions
|
|
@ -41,14 +41,11 @@ const extractSubTargets = target => {
|
|||
const isRegex = target.charCodeAt(0) === 0x2F /* / */;
|
||||
if ( isRegex === false ) {
|
||||
const pathPos = target.indexOf('/');
|
||||
if ( pathPos !== -1 ) {
|
||||
return {
|
||||
isRegex,
|
||||
hn: target.slice(0, pathPos),
|
||||
pn: target.slice(pathPos),
|
||||
};
|
||||
}
|
||||
return { isRegex, hn: target };
|
||||
return {
|
||||
isRegex,
|
||||
hn: target.slice(0, pathPos),
|
||||
pn: target.slice(pathPos),
|
||||
};
|
||||
}
|
||||
const pathPos = target.indexOf('\\/');
|
||||
if ( pathPos !== -1 ) {
|
||||
|
|
@ -191,16 +188,12 @@ export class StaticExtFilteringHostnameDB {
|
|||
}
|
||||
|
||||
#matcherTest(matcher, hn, pn) {
|
||||
if ( matcher.isRegex ) {
|
||||
if ( this.#restrTest(matcher.hn, hn) === false ) { return false; }
|
||||
if ( matcher.pn === undefined ) { return true; }
|
||||
return this.#restrTest(matcher.pn, pn);
|
||||
if ( matcher.isRegex === false ) {
|
||||
return pn.startsWith(matcher.pn);
|
||||
}
|
||||
if ( hn.endsWith(matcher.hn) === false ) { return false; }
|
||||
if ( hn.length !== matcher.hn.length ) {
|
||||
if ( hn.at(hn.length - matcher.hn.length - 1) !== '.' ) { return false; }
|
||||
}
|
||||
return pn.startsWith(matcher.pn);
|
||||
if ( this.#restrTest(matcher.hn, hn) === false ) { return false; }
|
||||
if ( matcher.pn === undefined ) { return true; }
|
||||
return this.#restrTest(matcher.pn, pn);
|
||||
}
|
||||
|
||||
#restrTest(restr, s) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue