[skip ci] UserScript: Fix cors check pt 2

This commit is contained in:
Vendicated 2023-04-28 01:13:42 +02:00
parent 5be86f9bd1
commit 5f5d4b8961
No known key found for this signature in database
GPG Key ID: A1DC0CFB5615D905

View File

@ -59,7 +59,9 @@ 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"]?.toLowerCase().split(/,\s/g);
const methods = headers["access-control-allow-methods"]?.toLowerCase()
.split(",")
.map(s => s.trim());
if (methods && !methods.includes(method.toLowerCase())) return false;
return true;