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 <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>
  • 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.