diff --git a/lib/util.js b/lib/util.js index c6c543d5b3350b..5a16076b7c8415 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,5 +1,7 @@ 'use strict'; +const Url = require('url').Url; + const formatRegExp = /%[sdj%]/g; exports.format = function(f) { if (typeof f !== 'string') { @@ -632,7 +634,8 @@ exports.inherits = function(ctor, superCtor) { exports._extend = function(origin, add) { // Don't do anything if add isn't an object if (add === null || typeof add !== 'object') return origin; - if (typeof add.toJSON === 'function') add = add.toJSON(); + // For compatibility with Url objects + if (add instanceof Url) add = add.toJSON(); var keys = Object.keys(add); var i = keys.length;