Browse Source

fix: autosens logs to be evaluated line by line

Marc R Kellerman 1 year ago
parent
commit
dd38115d98
1 changed files with 7 additions and 5 deletions
  1. 7 5
      FreeAPS/Sources/APS/OpenAPS/JavaScriptWorker.swift

+ 7 - 5
FreeAPS/Sources/APS/OpenAPS/JavaScriptWorker.swift

@@ -63,11 +63,13 @@ final class JavaScriptWorker {
         if outputLogs.isEmpty { return }
 
         if logContext == "prepare/autosens.js" {
-            outputLogs = outputLogs.replacingOccurrences(
-                of: "((?:[\\=\\+\\-]\\n)+)?\\d+h\\n((?:[\\=\\+\\-]\\n)+)?",
-                with: "",
-                options: .regularExpression
-            )
+            outputLogs = outputLogs.split(separator: "\n").map { logLine in
+                logLine.replacingOccurrences(
+                    of: "^[-+=]|\\d{1,2}h$",
+                    with: "",
+                    options: .regularExpression
+                )
+            }.joined(separator: "\n")
         }
 
         if !outputLogs.isEmpty {