4444 * @see {@link https://tools.ietf.org/html/rfc3986#section-3 }
4545 */
4646
47- const url = require ( 'url' ) ,
47+ const domainToASCII = require ( 'url' ) . domainToASCII ,
4848
4949 encodeSet = require ( './encode-set' ) ,
5050
@@ -69,38 +69,7 @@ const url = require('url'),
6969 OBJECT = 'object' ,
7070
7171 PATH_SEPARATOR = '/' ,
72- DOMAIN_SEPARATOR = '.' ,
73-
74- /**
75- * Returns the Punycode ASCII serialization of the domain.
76- *
77- * @note `url.domainToASCII` returns empty string for invalid domain.
78- *
79- * @todo Remove `punycode` dependency on Node version >= 6.13.0.
80- * For backward compatibility, fallback to `punycode` as url.domainToASCII.
81- *
82- * @private
83- * @function
84- * @param {String } domain domain name
85- * @returns {String } punycode encoded domain name
86- */
87- domainToASCII = ( function ( ) {
88- const domainToASCII = url . domainToASCII ;
89-
90- // @note In Electron v3.1.8, the Node.js native url.domainToASCII
91- // doesn't work as expected. ¯\_(ツ)_/¯
92- // so, check if it convert's '😎' to 'xn--s28h' or not.
93- // @todo Remove this hack on Electron >= 4
94- /* istanbul ignore next */
95- if ( typeof domainToASCII === 'function' && domainToASCII ( '😎' ) === 'xn--s28h' ) {
96- // use faster native method
97- return domainToASCII ;
98- }
99-
100- // else, lazy load `punycode` dependency
101- /* istanbul ignore next */
102- return require ( 'punycode' ) . toASCII ;
103- } ( ) ) ;
72+ DOMAIN_SEPARATOR = '.' ;
10473
10574/**
10675 * Returns the Punycode ASCII serialization of the domain.
0 commit comments