refactor: simplify error formatter in web-server modal

This commit is contained in:
KodekaTeam committed 2026-06-04 00:52:42 +07:00
1 parent 42c2fb96b7
commit 4f634530da
3 files changed
+45 -5

No files matched your search

@@ -5,6 +5,7 @@ import { Server } from "@prisma/client";
import { execStrict } from "./commands";
import { execDocker, execDockerStrict } from "./internal/docker";
import { privilegedCommand } from "./internal/privilege";
import { escapeShellArg } from "./internal/shell";
// NOTE: This file is a modularization of ssh.service.ts (domain: docker-containers).
@@ -105,10 +106,6 @@ export async function dockerLogs(
return result.stdout + result.stderr;
}
function escapeShellArg(value: string): string {
return `'${value.replace(/'/g, `'"'"'`)}'`;
}
const SAFE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$/;
const SAFE_ENV_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
const SAFE_RESTART_POLICY_PATTERN =
@@ -1,3 +1,3 @@
export function escapeShellArg(value: string): string {
return `'${value.replace(/'/g, `"'"'"`)}'`;
return `'${value.replace(/'/g, `'\\''`)}'`;
}