GeezerVison is showing github.com — lib: use validateString · nodejs/node@4ee4679
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/_http_client.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -80,6 +80,7 @@ const { |
80 | 80 | const { |
81 | 81 | validateInteger, |
82 | 82 | validateBoolean, |
| 83 | + validateString, |
83 | 84 | } = require('internal/validators'); |
84 | 85 | const { getTimerDuration } = require('internal/timers'); |
85 | 86 | const { |
@@ -270,12 +271,11 @@ function ClientRequest(input, options, cb) { |
270 | 271 | delete optsWithoutSignal.signal; |
271 | 272 | } |
272 | 273 | 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'); |
276 | 276 | } |
277 | 277 |
|
278 | | - if (methodIsString && method) { |
| 278 | + if (method) { |
279 | 279 | if (!checkIsHttpToken(method)) { |
280 | 280 | throw new ERR_INVALID_HTTP_TOKEN('Method', method); |
281 | 281 | } |
|