| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -90,6 +90,8 @@ const { Buffer } = require('buffer'); | |||
| 90 | 90 | ||
| 91 | 91 | const { | |
| 92 | 92 | validateFunction, | |
| 93 | + validateObject, | ||
| 94 | + kValidateObjectAllowObjects, | ||
| 93 | 95 | } = require('internal/validators'); | |
| 94 | 96 | ||
| 95 | 97 | const { percentDecode } = require('internal/data_url'); | |
@@ -1430,6 +1432,7 @@ function domainToUnicode(domain) { | |||
| 1430 | 1432 | * @returns {Record<string, unknown>} | |
| 1431 | 1433 | */ | |
| 1432 | 1434 | function urlToHttpOptions(url) { | |
| 1435 | + validateObject(url, 'url', kValidateObjectAllowObjects); | ||
| 1433 | 1436 | const { hostname, pathname, port, username, password, search } = url; | |
| 1434 | 1437 | const options = { | |
| 1435 | 1438 | __proto__: null, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,3 +35,12 @@ assert.strictEqual(copiedOpts.pathname, undefined); | |||
| 35 | 35 | assert.strictEqual(copiedOpts.search, undefined); | |
| 36 | 36 | assert.strictEqual(copiedOpts.hash, undefined); | |
| 37 | 37 | assert.strictEqual(copiedOpts.href, undefined); | |
| 38 | + | ||
| 39 | + // Test when passed an invalid argument | ||
| 40 | + assert.throws(() => { | ||
| 41 | + urlToHttpOptions('http://127.0.0.1'); | ||
| 42 | + }, { | ||
| 43 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 44 | + message: 'The "url" argument must be of type object. Received type string (\'http://127.0.0.1\')', | ||
| 45 | + name: 'TypeError' | ||
| 46 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments