◐ Shell
clean mode source ↗

lib: use validateString · nodejs/node@4ee4679

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

}