From 63449972d13f8321bd754879660549eda00844de Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Tue, 28 Feb 2017 10:06:25 +0100 Subject: [PATCH] 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 Reviewed-By: Timothy Gu Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen Reviewed-By: Jackson Tian --- lib/url.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/url.js b/lib/url.js index 59821b67ca3bfc..8579f2656b9eac 100644 --- a/lib/url.js +++ b/lib/url.js @@ -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;