added sanity check

This commit is contained in:
David Meincke
2023-06-02 10:43:19 +02:00
parent 65a6312b8e
commit 221183962c
7 changed files with 28 additions and 23 deletions
+17
View File
@@ -0,0 +1,17 @@
export function sanityConvert(code: string, maxLoops: number = 2000) {
var beforeConidition = "var conditionCount = " + maxLoops + "; \n";
var insideCondition = "\n --conditionCount; \n if (conditionCount <= 0) { break; } \n";
const regex = /(while|for|foreach)(\s*\([^)]*\)\s*)({[^}]*}|[^{;]*;?)/gs;
const output = code.replace(regex, (match, p1, p2, p3) => {
let statement = p3.trim();
if (statement.startsWith('{') && statement.endsWith('}')) {
statement = statement.replace('{', '{' + insideCondition);
} else {
statement = statement.endsWith(';') ? statement.slice(0, -1) : statement;
statement = `{${insideCondition}${statement};}`;
}
return `${beforeConidition}${p1}${p2}${statement}`;
});
return output;
}
+2 -2
View File
@@ -1,5 +1,5 @@
var apiUrl = "https://codeeditor-api.davidssoft.com/";
//var apiUrl = "https://codeeditor-api.azurewebsites.net/";
//var apiUrl = "https://codeeditor-api.davidssoft.com/";
var apiUrl = "https://codeeditor-api.azurewebsites.net/";
export function hasSession() {
var localstorageSessionId = localStorage.getItem("sessionId");
+1 -1
View File
@@ -9,7 +9,7 @@ export function IsLocalhost(): boolean {
export function GetOutputFrameUrl(path: string = ""): string {
var v = "?v=" + (+new Date());
if (IsLocalhost()) {
return "http://127.0.0.1:8021/" + path + v;
return "http://localhost:8021/" + path + v;
}
else {
return "https://outputframe.davidmeincke.dk/" + path + v;