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)) {