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: nodejs#36679
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Zeyu Yang <[email protected]>
Reviewed-By: Pooja D P <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
rchougule authored and yashLadha committed Jan 9, 2021
1 parent e68299a commit 3af175f
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 3af175f

Please sign in to comment.