Add and use array helper.
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 18 Oct 2020 10:19:58 +0000 (12:19 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 18 Oct 2020 10:19:58 +0000 (12:19 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.js
src/utils/Utils.js

index 2bed5ff0ef5ffc69c209248bccfb1ab2fc85b8c5..f68607863c1a1a9882d2f3be5cddf068d3a190fe 100644 (file)
@@ -737,7 +737,7 @@ class ChargingStation {
   }
 
   hasAuthorizedTags() {
-    return Array.isArray(this._authorizedTags) && this._authorizedTags.length > 0;
+    return !Utils.isEmptyArray(this._authorizedTags);
   }
 
   getRandomTagId() {
index f25f48b2b8a81d03b78a72a2c56dd6a4fd5ebf6e..15ee30711ec2c3645626b0e6af071abd212c71aa 100644 (file)
@@ -145,6 +145,13 @@ class Utils {
     }
     return false;
   }
+
+  static isEmptyArray(object) {
+    if (Array.isArray(object) && object.length > 0) {
+      return false;
+    }
+    return true;
+  }
 }
 
 module.exports = Utils;