From a38ad0709cf7f53dfa884df553eee1293e433e77 Mon Sep 17 00:00:00 2001 From: Rohan Chougule Date: Tue, 29 Dec 2020 23:51:33 +0530 Subject: [PATCH] http2: refactor to use primordials instead of .indexOf PR-URL: https://github.com/nodejs/node/pull/36679 Reviewed-By: Antoine du Hamel Reviewed-By: Zeyu Yang Reviewed-By: Pooja D P Reviewed-By: James M Snell Reviewed-By: Rich Trott --- lib/internal/http2/compat.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index e7a0cbb436b1f5..d116cb9d5ee925 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -11,6 +11,7 @@ const { ObjectPrototypeHasOwnProperty, ReflectApply, ReflectGetPrototypeOf, + StringPrototypeIncludes, StringPrototypeToLowerCase, StringPrototypeTrim, Symbol, @@ -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)) {