Skip to content

Commit 50e7e6e

Browse files
committed
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.
1 parent fb71ba4 commit 50e7e6e

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)