From 12c78aa1cc8de6583b8a325e92e37981582d911f 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 --- 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)) {