From 1a83a521ca8b65df59a5d8a1730afa5b789c22b3 Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Fri, 1 May 2020 16:07:16 +0300 Subject: [PATCH] [bugfix] Fix incorrect typeof checks, fixes #5483 --- src/lib/locale/locales.js | 12 ++++++------ src/lib/moment/prototype.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/locale/locales.js b/src/lib/locale/locales.js index 9886aa96b..14ff7cf00 100644 --- a/src/lib/locale/locales.js +++ b/src/lib/locale/locales.js @@ -64,7 +64,8 @@ function chooseLocale(names) { function loadLocale(name) { var oldLocale = null, - aliasedRequire; + aliasedRequire, + localePath; // TODO: Find a better way to register and load all the locales in Node if ( locales[name] === undefined && @@ -75,11 +76,10 @@ function loadLocale(name) { try { oldLocale = globalLocale._abbr; aliasedRequire = require; - aliasedRequire( - (typeof __dirname !== undefined ? __dirname : '.') + - '/locale/' + - name - ); + localePath = (typeof __dirname !== 'undefined' ? __dirname : '.') + + '/locale/' + + name; + aliasedRequire(localePath); getSetGlobalLocale(oldLocale); } catch (e) { // mark as not found to avoid repeating expensive file require call causing high CPU diff --git a/src/lib/moment/prototype.js b/src/lib/moment/prototype.js index c45630cb7..b4565ab6e 100644 --- a/src/lib/moment/prototype.js +++ b/src/lib/moment/prototype.js @@ -58,7 +58,7 @@ proto.toObject = toObject; proto.toDate = toDate; proto.toISOString = toISOString; proto.inspect = inspect; -if (typeof Symbol !== undefined && Symbol.for != null) { +if (typeof Symbol !== 'undefined' && Symbol.for != null) { proto[Symbol.for('nodejs.util.inspect.custom')] = function () { return 'Moment<' + this.format() + '>'; }; -- 2.47.2