Skip to content

Commit

Permalink
url: use hasIntl instead of try-catch
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
watilde authored and MylesBorins committed Apr 19, 2017
1 parent 3419b7a commit 6344997
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/url.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
'use strict';

function importPunycode() {
try {
return process.binding('icu');
} catch (e) {
return require('punycode');
}
}

const { toASCII } = importPunycode();
const { toASCII } = process.binding('config').hasIntl ?
process.binding('icu') : require('punycode');

exports.parse = urlParse;
exports.resolve = urlResolve;
Expand Down

0 comments on commit 6344997

Please sign in to comment.