Skip to content

Commit

Permalink
Only call toJSON for Url objects
Browse files Browse the repository at this point in the history
  • Loading branch information
petkaantonov committed Feb 26, 2015
1 parent ac79e2e commit f7de4dc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const Url = require('url').Url;

const formatRegExp = /%[sdj%]/g;
exports.format = function(f) {
if (typeof f !== 'string') {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f7de4dc

Please sign in to comment.