diff --git a/lib/url.js b/lib/url.js index 530632a50bad45..6227c8a057a4ce 100644 --- a/lib/url.js +++ b/lib/url.js @@ -23,19 +23,19 @@ const { toASCII } = process.binding('config').hasIntl ? process.binding('icu') : require('punycode'); + const { hexTable } = require('internal/querystring'); -const internalUrl = require('internal/url'); -exports.parse = urlParse; -exports.resolve = urlResolve; -exports.resolveObject = urlResolveObject; -exports.format = urlFormat; -exports.URL = internalUrl.URL; -exports.URLSearchParams = internalUrl.URLSearchParams; -exports.domainToASCII = internalUrl.domainToASCII; -exports.domainToUnicode = internalUrl.domainToUnicode; +// WHATWG URL implementation provided by internal/url +const { + URL, + URLSearchParams, + domainToASCII, + domainToUnicode, + formatSymbol +} = require('internal/url'); -exports.Url = Url; +// Original url.parse() API function Url() { this.protocol = null; @@ -559,7 +559,7 @@ function urlFormat(obj, options) { throw new TypeError('Parameter "urlObj" must be an object, not ' + (obj === null ? 'null' : typeof obj)); } else if (!(obj instanceof Url)) { - var format = obj[internalUrl.formatSymbol]; + var format = obj[formatSymbol]; return format ? format.call(obj, options) : Url.prototype.format.call(obj); @@ -1030,3 +1030,18 @@ function encodeAuth(str) { return out + str.slice(lastPos); return out; } + +module.exports = { + // Original API + Url, + parse: urlParse, + resolve: urlResolve, + resolveObject: urlResolveObject, + format: urlFormat, + + // WHATWG API + URL, + URLSearchParams, + domainToASCII, + domainToUnicode +};