diff options
Diffstat (limited to 'lib/url.js')
-rw-r--r-- | lib/url.js | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/url.js b/lib/url.js index fcddd4afaf..b3b05f4a89 100644 --- a/lib/url.js +++ b/lib/url.js @@ -550,22 +550,23 @@ function autoEscapeStr(rest) { } // format a parsed object into a url string -function urlFormat(obj, options) { +function urlFormat(urlObject, 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 + // If it's an object, this is a no-op. + // this way, you can call urlParse() on strings // to clean up potentially wonky urls. - if (typeof obj === 'string') { - obj = urlParse(obj); - } else if (typeof obj !== 'object' || obj === null) { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'urlObj', 'object', obj); - } else if (!(obj instanceof Url)) { - var format = obj[formatSymbol]; + if (typeof urlObject === 'string') { + urlObject = urlParse(urlObject); + } else if (typeof urlObject !== 'object' || urlObject === null) { + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'urlObject', + ['object', 'string'], urlObject); + } else if (!(urlObject instanceof Url)) { + var format = urlObject[formatSymbol]; return format ? - format.call(obj, options) : - Url.prototype.format.call(obj); + format.call(urlObject, options) : + Url.prototype.format.call(urlObject); } - return obj.format(); + return urlObject.format(); } Url.prototype.format = function format() { |