Skip to content

Commit 4987dd1

Browse files
committed
Only call toJSON for Url objects
1 parent c37754c commit 4987dd1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/util.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const Url = require('url').Url;
4+
35
const formatRegExp = /%[sdj%]/g;
46
exports.format = function(f) {
57
if (typeof f !== 'string') {
@@ -632,7 +634,8 @@ exports.inherits = function(ctor, superCtor) {
632634
exports._extend = function(origin, add) {
633635
// Don't do anything if add isn't an object
634636
if (add === null || typeof add !== 'object') return origin;
635-
if (typeof add.toJSON === 'function') add = add.toJSON();
637+
// For compatibility with Url objects
638+
if (add instanceof Url) add = add.toJSON();
636639

637640
var keys = Object.keys(add);
638641
var i = keys.length;

0 commit comments

Comments
 (0)