Skip to content

Commit cd857a9

Browse files
hotpineappleaduh95
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 212263a commit cd857a9

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
@@ -78,6 +78,7 @@ const {
7878
const {
7979
validateInteger,
8080
validateBoolean,
81+
validateString,
8182
} = require('internal/validators');
8283
const { getTimerDuration } = require('internal/timers');
8384
const {
@@ -218,12 +219,11 @@ function ClientRequest(input, options, cb) {
218219
delete optsWithoutSignal.signal;
219220
}
220221
let method = options.method;
221-
const methodIsString = (typeof method === 'string');
222-
if (method !== null && method !== undefined && !methodIsString) {
223-
throw new ERR_INVALID_ARG_TYPE('options.method', 'string', method);
222+
if (method != null) {
223+
validateString(method, 'options.method');
224224
}
225225

226-
if (methodIsString && method) {
226+
if (method) {
227227
if (!checkIsHttpToken(method)) {
228228
throw new ERR_INVALID_HTTP_TOKEN('Method', method);
229229
}

0 commit comments

Comments
 (0)