From 44d407f24cf76f0a7a00b7886ae151a5c95e2859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Yves=20G=C3=A9rardy?= Date: Sat, 16 Jan 2021 23:07:16 +0100 Subject: [PATCH] [m.request] work around a bundler bug, fix #2647 --- request/request.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/request/request.js b/request/request.js index 648bb175..972565fa 100644 --- a/request/request.js +++ b/request/request.js @@ -67,7 +67,7 @@ module.exports = function($window, Promise, oncompletion) { function hasHeader(args, name) { for (var key in args.headers) { - if (hasOwn.call(args.headers, key) && name.test(key)) return true + if (hasOwn.call(args.headers, key) && key.toLowerCase() === name) return true } return false } @@ -90,10 +90,10 @@ module.exports = function($window, Promise, oncompletion) { xhr.open(method, url, args.async !== false, typeof args.user === "string" ? args.user : undefined, typeof args.password === "string" ? args.password : undefined) - if (assumeJSON && body != null && !hasHeader(args, /^content-type$/i)) { + if (assumeJSON && body != null && !hasHeader(args, "content-type")) { xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8") } - if (typeof args.deserialize !== "function" && !hasHeader(args, /^accept$/i)) { + if (typeof args.deserialize !== "function" && !hasHeader(args, "accept")) { xhr.setRequestHeader("Accept", "application/json, text/*") } if (args.withCredentials) xhr.withCredentials = args.withCredentials