Fix getting the initiator URL when analysing scripts

main
Elbert Alias 2 years ago
parent 971b4cdd45
commit 90c5c6f41c

@ -415,11 +415,16 @@ const Driver = {
* @param {Object} request * @param {Object} request
*/ */
async onScriptRequestComplete(request) { async onScriptRequestComplete(request) {
if (await Driver.isDisabledDomain(request.url)) { const initiatorUrl = request.initiator || request.documentUrl || request.url
if (
(await Driver.isDisabledDomain(initiatorUrl)) ||
(await Driver.isDisabledDomain(request.url))
) {
return return
} }
const { hostname } = new URL(request.documentUrl) const { hostname } = new URL(initiatorUrl)
if (!Driver.cache.hostnames[hostname]) { if (!Driver.cache.hostnames[hostname]) {
Driver.cache.hostnames[hostname] = {} Driver.cache.hostnames[hostname] = {}
@ -439,9 +444,7 @@ const Driver = {
const scripts = (await response.text()).slice(0, 500000) const scripts = (await response.text()).slice(0, 500000)
Driver.onDetect(request.documentUrl, analyze({ scripts })).catch( Driver.onDetect(initiatorUrl, analyze({ scripts })).catch(Driver.error)
Driver.error
)
}, },
/** /**