From 5f5d4b896193a632d3bc6e16048ec92843e01c71 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 01:13:42 +0200 Subject: [PATCH] [skip ci] UserScript: Fix cors check pt 2 --- browser/GMPolyfill.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser/GMPolyfill.js b/browser/GMPolyfill.js index beee9156..1f74a7c6 100644 --- a/browser/GMPolyfill.js +++ b/browser/GMPolyfill.js @@ -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;