Skip to content

Commit

Permalink
[m.request] work around a bundler bug, fix #2647
Browse files Browse the repository at this point in the history
  • Loading branch information
pygy authored Jan 16, 2021
1 parent f5b41aa commit e9d54b5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions request/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit e9d54b5

Please sign in to comment.