summaryrefslogtreecommitdiff
path: root/lib/url.js
diff options
context:
space:
mode:
authorDaijiro Wachi <daijiro.wachi@gmail.com>2017-02-28 10:06:25 +0100
committerJames M Snell <jasnell@gmail.com>2017-03-04 08:04:08 -0800
commitcccc6d8545c0ebd83f934b9734f5605aaeb000f2 (patch)
treefac06eb9f2d2a878e59fb94ef08f1ce2b397b176 /lib/url.js
parent3b05153cdccdaaa74e21414541d70de7937f7965 (diff)
downloadandroid-node-v8-cccc6d8545c0ebd83f934b9734f5605aaeb000f2.tar.gz
android-node-v8-cccc6d8545c0ebd83f934b9734f5605aaeb000f2.tar.bz2
android-node-v8-cccc6d8545c0ebd83f934b9734f5605aaeb000f2.zip
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. PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'lib/url.js')
-rw-r--r--lib/url.js12
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/url.js b/lib/url.js
index 2db780c7eb..1623de56ca 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -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;