v1.3.6: merge some bugfix PRs

This commit is contained in:
AJ ONeal 2018-07-12 03:12:49 -06:00
parent c880788e9a
commit 49daa68225
2 changed files with 7 additions and 5 deletions

View File

@ -29,14 +29,16 @@ function mergeOrDelete(defaults, updates) {
return updates; return updates;
} }
// retrieves an existing header, case-sensitive
function getHeaderName(reqOpts, header) { function getHeaderName(reqOpts, header) {
var headers = {}; var headerNames = {};
Object.keys(reqOpts.headers).forEach(function (key) { Object.keys(reqOpts.headers).forEach(function (casedName) {
headers[key.toLowerCase()] = key; headerNames[casedName.toLowerCase()] = casedName;
}); });
// returns the key, which in erroneous cases could be an empty string // returns the key, which in erroneous cases could be an empty string
return headers[header.toLowerCase()]; return headerNames[header.toLowerCase()];
} }
// returns whether or not a header exists, case-insensitive
function hasHeader(reqOpts, header) { function hasHeader(reqOpts, header) {
return 'undefined' !== typeof getHeaderName(reqOpts, header); return 'undefined' !== typeof getHeaderName(reqOpts, header);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@coolaj86/urequest", "name": "@coolaj86/urequest",
"version": "1.3.5", "version": "1.3.6",
"description": "A lightweight drop-in replacement for request", "description": "A lightweight drop-in replacement for request",
"main": "index.js", "main": "index.js",
"files": [ "files": [