diff --git a/lib/core/constants.js b/lib/core/constants.js index 6ec770dd533..000c0194909 100644 --- a/lib/core/constants.js +++ b/lib/core/constants.js @@ -1,10 +1,9 @@ 'use strict' -/** @type {Record} */ -const headerNameLowerCasedRecord = {} - -// https://developer.mozilla.org/docs/Web/HTTP/Headers -const wellknownHeaderNames = [ +/** + * @see https://developer.mozilla.org/docs/Web/HTTP/Headers + */ +const wellknownHeaderNames = /** @type {const} */ ([ 'Accept', 'Accept-Encoding', 'Accept-Language', @@ -100,7 +99,13 @@ const wellknownHeaderNames = [ 'X-Powered-By', 'X-Requested-With', 'X-XSS-Protection' -] +]) + +/** @type {Record, string>} */ +const headerNameLowerCasedRecord = {} + +// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`. +Object.setPrototypeOf(headerNameLowerCasedRecord, null) for (let i = 0; i < wellknownHeaderNames.length; ++i) { const key = wellknownHeaderNames[i] @@ -109,9 +114,6 @@ for (let i = 0; i < wellknownHeaderNames.length; ++i) { lowerCasedKey } -// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`. -Object.setPrototypeOf(headerNameLowerCasedRecord, null) - module.exports = { wellknownHeaderNames, headerNameLowerCasedRecord