From 24e6fcce8b61fe3b94dc5d86af0ce15e180a367a 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 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/url.js b/lib/url.js index 42853e346c474f..cc098593a5f238 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;