Fix referer sometimes missing

This commit is contained in:
Kuba Orlik 2021-11-09 21:57:19 +01:00
parent a859d0239f
commit 6a29c8ed40

View File

@ -117,7 +117,7 @@ export default class ExtendedRequest {
getReferer() { getReferer() {
return ( return (
this.data.requestHeaders.filter((h) => h.name === "Referer")?.[0].value || this.data.requestHeaders.filter((h) => h.name === "Referer")[0]?.value ||
"missing-referrer" "missing-referrer"
); );
} }
@ -126,10 +126,14 @@ export default class ExtendedRequest {
const url = new URL(this.origin); const url = new URL(this.origin);
const host = url.host; const host = url.host;
const path = url.pathname; const path = url.pathname;
const shorthost = getshorthost(host);
return ( return (
this.getReferer().includes(host) || this.getReferer().includes(host) ||
this.stolenData.filter( this.stolenData.filter(
(entry) => entry.value.includes(host) || entry.value.includes(path) (entry) =>
entry.value.includes(host) ||
entry.value.includes(path) ||
entry.value.includes(shorthost)
).length > 0 ).length > 0
); );
} }