From: Iskren Chernev Date: Fri, 1 May 2020 13:07:16 +0000 (+0300) Subject: [bugfix] Fix incorrect typeof checks, fixes #5483 X-Git-Tag: 2.25.1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a83a521ca8b65df59a5d8a1730afa5b789c22b3;p=thirdparty%2Fmoment.git [bugfix] Fix incorrect typeof checks, fixes #5483 --- 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() + '>'; };