diff --git a/lib/core/constants.js b/lib/core/constants.js index 000c0194909..a82a1bc0310 100644 --- a/lib/core/constants.js +++ b/lib/core/constants.js @@ -102,10 +102,8 @@ const wellknownHeaderNames = /** @type {const} */ ([ ]) /** @type {Record, string>} */ -const headerNameLowerCasedRecord = {} - // Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`. -Object.setPrototypeOf(headerNameLowerCasedRecord, null) +const headerNameLowerCasedRecord = Object.create(null) for (let i = 0; i < wellknownHeaderNames.length; ++i) { const key = wellknownHeaderNames[i] diff --git a/lib/core/util.js b/lib/core/util.js index 05dd11867d7..e35491091c8 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -819,7 +819,9 @@ function errorRequest (client, request, err) { const kEnumerableProperty = Object.create(null) kEnumerableProperty.enumerable = true -const normalizedMethodRecordsBase = { +// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`. + +const normalizedMethodRecordsBase = Object.setPrototypeOf({ delete: 'DELETE', DELETE: 'DELETE', get: 'GET', @@ -832,17 +834,13 @@ const normalizedMethodRecordsBase = { POST: 'POST', put: 'PUT', PUT: 'PUT' -} +}, null) -const normalizedMethodRecords = { +const normalizedMethodRecords = Object.setPrototypeOf({ ...normalizedMethodRecordsBase, patch: 'patch', PATCH: 'PATCH' -} - -// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`. -Object.setPrototypeOf(normalizedMethodRecordsBase, null) -Object.setPrototypeOf(normalizedMethodRecords, null) +}, null) module.exports = { kEnumerableProperty,