Closed Loirooriol closed 2 years ago
Thanks. It seemed fine in testing but I'll post a fix in a few minutes.
My bad, I forgot to test stand-alone images. Updated version 0.8.1 is making its way through the approval process.
I think it should be details.originUrl
? Also, != null
covers both null
and undefined
, see https://tc39.es/ecma262/#sec-islooselyequal, no need to check them both. And consider something like
function isExempt(url) {
if (url == null) return false;
let { hostname } = new URL(url);
return oPrefs.exemptSites.includes(hostname);
}
if (isExempt(details.url) || isExempt(details.documentUrl) || isExempt(details.originUrl)) {
return { requestHeaders: details.requestHeaders };
}
I was too busy to reply at that time, but hopefully by now you got the update with the fixes.
https://github.com/jscher2000/dont-accept-webp/blob/f63ee124c6ed57ee759270072b0b1fae4d55063b/background.js#L50
details.originUrl
is undefined for top-level resources.https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeSendHeaders#originurl
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeSendHeaders#documenturl
Anyways,
new URL(undefined)
throws and then the extension doesn't change the headers, and the server sends me a webp image.