Improve domain matching to reduce false positives (#172)
This commit is contained in:
@@ -31,11 +31,15 @@ function pathToDomain(path, currentHost) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var t = TldJS.parse(parts[key]);
|
var t = TldJS.parse(parts[key]);
|
||||||
|
|
||||||
|
// Part is considered to be a domain component in one of the following cases:
|
||||||
|
// - it is a valid domain with well-known TLD (github.com, login.github.com)
|
||||||
|
// - it is a valid domain with unknown TLD but the current host is it's subdomain (login.pi.hole)
|
||||||
|
// - it is or isnt a valid domain but the current host matches it EXACTLY (localhost, pi.hole)
|
||||||
if (
|
if (
|
||||||
t.isValid &&
|
t.isValid &&
|
||||||
((t.tldExists && t.domain !== null) ||
|
((t.domain !== null && (t.tldExists || currentHost.endsWith(`.${t.hostname}`))) ||
|
||||||
t.hostname === currentHost ||
|
currentHost === t.hostname)
|
||||||
currentHost.endsWith(`.${t.hostname}`))
|
|
||||||
) {
|
) {
|
||||||
return t.hostname;
|
return t.hostname;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user