Skip to content

Commit

Permalink
http2: refactor to use primordials instead of <string>.indexOf
Browse files Browse the repository at this point in the history
PR-URL: #36679
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
rchougule authored and danielleadams committed Jan 12, 2021
1 parent 7c7180a commit a38ad07
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
ObjectPrototypeHasOwnProperty,
ReflectApply,
ReflectGetPrototypeOf,
StringPrototypeIncludes,
StringPrototypeToLowerCase,
StringPrototypeTrim,
Symbol,
Expand Down Expand Up @@ -81,7 +82,9 @@ let statusConnectionHeaderWarned = false;
// close as possible to the current require('http') API

const assertValidHeader = hideStackFrames((name, value) => {
if (name === '' || typeof name !== 'string' || name.indexOf(' ') >= 0) {
if (name === '' ||
typeof name !== 'string' ||
StringPrototypeIncludes(name, ' ')) {
throw new ERR_INVALID_HTTP_TOKEN('Header name', name);
}
if (isPseudoHeader(name)) {
Expand Down

0 comments on commit a38ad07

Please sign in to comment.