build: use literal regexp for loopback address matching
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 29 Dec 2023 22:50:53 +0000 (23:50 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 29 Dec 2023 22:50:53 +0000 (23:50 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ui-server/UIServerUtils.ts

index 2056c2096fde585402c939700b32cd2b092b2e8d..a4f3bf51dafd7d6aa3612412617a58a4cd5dfa93 100644 (file)
@@ -49,12 +49,7 @@ export class UIServerUtils {
   }
 
   public static isLoopback (address: string): boolean {
-    // eslint-disable-next-line prefer-regex-literals
-    const isLoopbackRegExp = new RegExp(
-      // eslint-disable-next-line no-useless-escape
-      /^localhost$|^127(?:\.\d+){0,2}\.\d+$|^(?:0*\:)*?:?0*1$/,
-      'i'
-    )
-    return isLoopbackRegExp.test(address)
+    // eslint-disable-next-line no-useless-escape
+    return /^localhost$|^127(?:\.\d+){0,2}\.\d+$|^(?:0*\:)*?:?0*1$/i.test(address)
   }
 }