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