Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/core/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,8 @@ const wellknownHeaderNames = /** @type {const} */ ([
])

/** @type {Record<typeof wellknownHeaderNames[number]|Lowercase<typeof wellknownHeaderNames[number]>, 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]
Expand Down
14 changes: 6 additions & 8 deletions lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down