diff options
Diffstat (limited to 'lib/url.js')
-rw-r--r-- | lib/url.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/url.js b/lib/url.js index e4ced8e860..2b7dd6e532 100644 --- a/lib/url.js +++ b/lib/url.js @@ -538,19 +538,22 @@ function autoEscapeStr(rest) { } // format a parsed object into a url string -function urlFormat(obj) { +function urlFormat(obj, options) { // ensure it's an object, and not a string url. // If it's an obj, this is a no-op. // this way, you can call url_format() on strings // to clean up potentially wonky urls. - if (typeof obj === 'string') obj = urlParse(obj); - - else if (typeof obj !== 'object' || obj === null) + if (typeof obj === 'string') { + obj = urlParse(obj); + } else if (typeof obj !== 'object' || obj === null) { throw new TypeError('Parameter "urlObj" must be an object, not ' + obj === null ? 'null' : typeof obj); - - else if (!(obj instanceof Url)) return Url.prototype.format.call(obj); - + } else if (!(obj instanceof Url)) { + var format = obj[internalUrl.formatSymbol]; + return format ? + format.call(obj, options) : + Url.prototype.format.call(obj); + } return obj.format(); } |