url: move to module.exports = {} pattern
PR-URL: https://github.com/nodejs/node/pull/12717 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com
This commit is contained in:
parent
7c238be1e1
commit
b331ba6ca9
37
lib/url.js
37
lib/url.js
@ -23,19 +23,19 @@
|
|||||||
|
|
||||||
const { toASCII } = process.binding('config').hasIntl ?
|
const { toASCII } = process.binding('config').hasIntl ?
|
||||||
process.binding('icu') : require('punycode');
|
process.binding('icu') : require('punycode');
|
||||||
|
|
||||||
const { hexTable } = require('internal/querystring');
|
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() {
|
function Url() {
|
||||||
this.protocol = null;
|
this.protocol = null;
|
||||||
@ -559,7 +559,7 @@ function urlFormat(obj, options) {
|
|||||||
throw new TypeError('Parameter "urlObj" must be an object, not ' +
|
throw new TypeError('Parameter "urlObj" must be an object, not ' +
|
||||||
(obj === null ? 'null' : typeof obj));
|
(obj === null ? 'null' : typeof obj));
|
||||||
} else if (!(obj instanceof Url)) {
|
} else if (!(obj instanceof Url)) {
|
||||||
var format = obj[internalUrl.formatSymbol];
|
var format = obj[formatSymbol];
|
||||||
return format ?
|
return format ?
|
||||||
format.call(obj, options) :
|
format.call(obj, options) :
|
||||||
Url.prototype.format.call(obj);
|
Url.prototype.format.call(obj);
|
||||||
@ -1030,3 +1030,18 @@ function encodeAuth(str) {
|
|||||||
return out + str.slice(lastPos);
|
return out + str.slice(lastPos);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
// Original API
|
||||||
|
Url,
|
||||||
|
parse: urlParse,
|
||||||
|
resolve: urlResolve,
|
||||||
|
resolveObject: urlResolveObject,
|
||||||
|
format: urlFormat,
|
||||||
|
|
||||||
|
// WHATWG API
|
||||||
|
URL,
|
||||||
|
URLSearchParams,
|
||||||
|
domainToASCII,
|
||||||
|
domainToUnicode
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user