UserScript: Fix cors check

This commit is contained in:
V 2023-04-09 06:58:29 +02:00 committed by GitHub
parent c4a3d25d37
commit 40a7aa5079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,8 +59,8 @@ async function checkCors(url, method) {
const origin = headers["access-control-allow-origin"];
if (origin !== "*" && origin !== window.location.origin) return false;
const methods = headers["access-control-allow-methods"]?.split(/,\s/g);
if (methods && !methods.includes(method)) return false;
const methods = headers["access-control-allow-methods"]?.toLowerCase().split(/,\s/g);
if (methods && !methods.includes(method.toLowerCase())) return false;
return true;
}