http2: refactor to use primordials instead of <string>.indexOf

PR-URL: https://github.com/nodejs/node/pull/36679
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Rohan Chougule authored and Yash Ladha committed 2021-01-09 15:49:38 +05:30
1 parent e68299a8f7
commit 3af175fb5e
1 file changed
+4 -1
+4 -1
View File
@@ -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)) {