Skip to content

Commit a38ad07

Browse files
rchouguledanielleadams
authored andcommitted
http2: refactor to use primordials instead of <string>.indexOf
PR-URL: #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]>
1 parent 7c7180a commit a38ad07

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/internal/http2/compat.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
ObjectPrototypeHasOwnProperty,
1212
ReflectApply,
1313
ReflectGetPrototypeOf,
14+
StringPrototypeIncludes,
1415
StringPrototypeToLowerCase,
1516
StringPrototypeTrim,
1617
Symbol,
@@ -81,7 +82,9 @@ let statusConnectionHeaderWarned = false;
8182
// close as possible to the current require('http') API
8283

8384
const assertValidHeader = hideStackFrames((name, value) => {
84-
if (name === '' || typeof name !== 'string' || name.indexOf(' ') >= 0) {
85+
if (name === '' ||
86+
typeof name !== 'string' ||
87+
StringPrototypeIncludes(name, ' ')) {
8588
throw new ERR_INVALID_HTTP_TOKEN('Header name', name);
8689
}
8790
if (isPseudoHeader(name)) {

0 commit comments

Comments
 (0)