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 addaleax committed Mar 5, 2017
1 parent f56ca30 commit 24e6fcc
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/url.js
Original file line number Diff line number Diff line change
@@ -1,15 +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');
const { StorageObject, hexTable } = require('internal/querystring');
const internalUrl = require('internal/url');
exports.parse = urlParse;
Expand Down

0 comments on commit 24e6fcc

Please sign in to comment.