]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
[bugfix] Fix incorrect typeof checks, fixes #5483
authorIskren Chernev <iskren.chernev@gmail.com>
Fri, 1 May 2020 13:07:16 +0000 (16:07 +0300)
committerIskren Chernev <iskren.chernev@gmail.com>
Fri, 1 May 2020 13:07:16 +0000 (16:07 +0300)
src/lib/locale/locales.js
src/lib/moment/prototype.js

index 9886aa96b943a261193540d8632d0180e4ec4e9f..14ff7cf00c24928ea4a41368c8974a30234a29b4 100644 (file)
@@ -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
index c45630cb71bea8d09b4cbe6502fca68484c5f855..b4565ab6e0eb8ccda3669ba1a7c9d8c170f675cd 100644 (file)
@@ -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() + '>';
     };