Skip to content

Commit 529fabd

Browse files
committed
minor pr changes
1 parent bea9f5d commit 529fabd

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/core/util.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -905,14 +905,14 @@ Object.setPrototypeOf(normalizedMethodRecordsBase, null)
905905
Object.setPrototypeOf(normalizedMethodRecords, null)
906906

907907
/**
908-
* @param {Record<string, string | string[]> | Iterable<[string, string]> | string[]}
908+
* @param {Record<string, string | string[]> | Iterable<[string, string]> | string[]} opts
909909
* @returns {Record<string, string[] | string>}
910910
*/
911911
function normalizeHeaders (opts) {
912912
const headers = {}
913913
const src = opts.headers
914914

915-
if (src == null) return headers
915+
if (typeof src !== 'object' || src === null) return headers
916916

917917
if (Array.isArray(src)) {
918918
for (let i = 0; i < src.length; i += 2) {
@@ -934,12 +934,10 @@ function normalizeHeaders (opts) {
934934
return headers
935935
}
936936

937-
if (typeof src === 'object') {
938-
for (const key of Object.keys(src)) headers[key.toLowerCase()] = src[key]
939-
return headers
937+
for (const key of Object.keys(src)) {
938+
headers[key.toLowerCase()] = src[key]
940939
}
941-
942-
throw new InvalidArgumentError('opts.headers is not an object')
940+
return headers
943941
}
944942

945943
module.exports = {

0 commit comments

Comments
 (0)