Skip to content

Commit 4ee4679

Browse files
hotpineappleRafaelGSS
authored andcommitted
lib: use validateString
refactor validation code using validate function PR-URL: #59296 Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 95e9cab commit 4ee4679

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/_http_client.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const {
8080
const {
8181
validateInteger,
8282
validateBoolean,
83+
validateString,
8384
} = require('internal/validators');
8485
const { getTimerDuration } = require('internal/timers');
8586
const {
@@ -270,12 +271,11 @@ function ClientRequest(input, options, cb) {
270271
delete optsWithoutSignal.signal;
271272
}
272273
let method = options.method;
273-
const methodIsString = (typeof method === 'string');
274-
if (method !== null && method !== undefined && !methodIsString) {
275-
throw new ERR_INVALID_ARG_TYPE('options.method', 'string', method);
274+
if (method != null) {
275+
validateString(method, 'options.method');
276276
}
277277

278-
if (methodIsString && method) {
278+
if (method) {
279279
if (!checkIsHttpToken(method)) {
280280
throw new ERR_INVALID_HTTP_TOKEN('Method', method);
281281
}

0 commit comments

Comments
 (0)