Skip to content

Commit cc94000

Browse files
committed
Remove punycode fallback for Electron v3
1 parent 774470a commit cc94000

File tree

4 files changed

+8
-37
lines changed

4 files changed

+8
-37
lines changed

CHANGELOG.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
unreleased:
2+
chores:
3+
- Removed punycode fallback for Electron v3
4+
15
3.0.3:
26
date: 2021-07-25
37
fixed bugs:

encoder/index.js

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
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.

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
"test-system": "node npm/test-system.js",
3131
"test-unit": "nyc --nycrc-path=.nycrc.js node npm/test-unit.js"
3232
},
33-
"dependencies": {
34-
"punycode": "^2.1.1"
35-
},
3633
"devDependencies": {
3734
"@postman/csv-parse": "^4.0.2",
3835
"@postman/shipit": "^0.3.0",

0 commit comments

Comments
 (0)