Skip to content

Commit 24e6fcc

Browse files
watildeaddaleax
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 <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jackson Tian <[email protected]>
1 parent f56ca30 commit 24e6fcc

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lib/url.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +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();
12-
3+
const { toASCII } = process.binding('config').hasIntl ?
4+
process.binding('icu') : require('punycode');
135
const { StorageObject, hexTable } = require('internal/querystring');
146
const internalUrl = require('internal/url');
157
exports.parse = urlParse;

0 commit comments

Comments
 (0)