url: add type checking to urlToHttpOptions() · nodejs/node@6458867

Original file line numberDiff line numberDiff line change

@@ -91,6 +91,8 @@ const { Buffer } = require('buffer');

9191
9292

const {

9393

validateFunction,

94+

validateObject,

95+

kValidateObjectAllowObjects,

9496

} = require('internal/validators');

9597
9698

const { percentDecode } = require('internal/data_url');

@@ -1431,6 +1433,7 @@ function domainToUnicode(domain) {

14311433

* @returns {Record<string, unknown>}

14321434

*/

14331435

function urlToHttpOptions(url) {

1436+

validateObject(url, 'url', kValidateObjectAllowObjects);

14341437

const { hostname, pathname, port, username, password, search } = url;

14351438

const options = {

14361439

__proto__: null,