Skip to content

Commit 6344997

Browse files
watildeMylesBorins
authored andcommitted
url: use hasIntl instead of try-catch
Like the other internal modules, we should use `process.binding('config').hasIntl` instead of `try-catch` to make sure `icu` is bonded or not. PR-URL: #11571 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
1 parent 3419b7a commit 6344997

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

lib/url.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
'use strict';
22

3-
function importPunycode() {
4-
try {
5-
return process.binding('icu');
6-
} catch (e) {
7-
return require('punycode');
8-
}
9-
}
10-
11-
const { toASCII } = importPunycode();
3+
const { toASCII } = process.binding('config').hasIntl ?
4+
process.binding('icu') : require('punycode');
125

136
exports.parse = urlParse;
147
exports.resolve = urlResolve;

0 commit comments

Comments
 (0)