Fix Content-Type test false negative

Some servers will append extra stuff (like encoding) to the `Content-Type` response header. This fixes that
This commit is contained in:
Victor Westerlund 2021-10-31 13:23:58 +01:00
parent b2556f1ced
commit 4073785f93

View file

@ -64,7 +64,7 @@ export default class Monkeydo extends MonkeyWorker {
const fetchManifest = await fetch(manifest); const fetchManifest = await fetch(manifest);
// If the URL parsed but the fetch response is invalid, give up and throw an error // If the URL parsed but the fetch response is invalid, give up and throw an error
if(!fetchManifest.ok || fetchManifest.headers.get("Content-Type") !== "application/json") { if(!fetchManifest.ok || !fetchManifest.headers.get("Content-Type")?.includes("application/json")) {
throw new TypeError(errorPrefix + "Invalid response Content-Type or HTTP status"); throw new TypeError(errorPrefix + "Invalid response Content-Type or HTTP status");
} }
data = await fetchManifest.json(); data = await fetchManifest.json();