From 4ee467905dd11b9367afc4b56f6af2ce2e6d5b63 Mon Sep 17 00:00:00 2001 From: hotpineapple <77835382+hotpineapple@users.noreply.github.com> Date: Sat, 2 Aug 2025 20:31:47 +0900 Subject: [PATCH] lib: use validateString refactor validation code using validate function PR-URL: https://github.com/nodejs/node/pull/59296 Reviewed-By: Ethan Arrowood Reviewed-By: Luigi Pinca Reviewed-By: Zeyu "Alex" Yang Reviewed-By: Filip Skokan --- lib/_http_client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index f5d3d711a7f..63a7befc8eb 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -80,6 +80,7 @@ const { const { validateInteger, validateBoolean, + validateString, } = require('internal/validators'); const { getTimerDuration } = require('internal/timers'); const { @@ -270,12 +271,11 @@ function ClientRequest(input, options, cb) { delete optsWithoutSignal.signal; } let method = options.method; - const methodIsString = (typeof method === 'string'); - if (method !== null && method !== undefined && !methodIsString) { - throw new ERR_INVALID_ARG_TYPE('options.method', 'string', method); + if (method != null) { + validateString(method, 'options.method'); } - if (methodIsString && method) { + if (method) { if (!checkIsHttpToken(method)) { throw new ERR_INVALID_HTTP_TOKEN('Method', method); }