Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: minor constants change #3726

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
Loading