fix: stabilize media paths and logs
This commit is contained in:
@@ -20,6 +20,7 @@ const normalizeText = (value?: string) =>
|
||||
(value ?? "")
|
||||
.replace(/\r\n/g, "\n")
|
||||
.replace(/\r/g, "\n")
|
||||
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "")
|
||||
.split("\n")
|
||||
.map((line) => line.replace(/\s+$/u, ""))
|
||||
.join("\n")
|
||||
|
||||
@@ -18,9 +18,13 @@ function formatMediaAttachedLine(params: {
|
||||
}
|
||||
|
||||
export function buildInboundMediaNote(ctx: MsgContext): string | undefined {
|
||||
const hasPathsArray = Array.isArray(ctx.MediaPaths) && ctx.MediaPaths.length > 0;
|
||||
const paths = hasPathsArray
|
||||
const hasPathsArray =
|
||||
Array.isArray(ctx.MediaPaths) && ctx.MediaPaths.length > 0;
|
||||
const pathsFromArray = Array.isArray(ctx.MediaPaths)
|
||||
? ctx.MediaPaths
|
||||
: undefined;
|
||||
const paths = pathsFromArray && pathsFromArray.length > 0
|
||||
? pathsFromArray
|
||||
: ctx.MediaPath?.trim()
|
||||
? [ctx.MediaPath.trim()]
|
||||
: [];
|
||||
@@ -58,4 +62,3 @@ export function buildInboundMediaNote(ctx: MsgContext): string | undefined {
|
||||
}
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -857,8 +857,11 @@ async function stageSandboxMedia(params: {
|
||||
}) {
|
||||
const { ctx, sessionCtx, cfg, sessionKey, workspaceDir } = params;
|
||||
const hasPathsArray = Array.isArray(ctx.MediaPaths) && ctx.MediaPaths.length > 0;
|
||||
const rawPaths = hasPathsArray
|
||||
const pathsFromArray = Array.isArray(ctx.MediaPaths)
|
||||
? ctx.MediaPaths
|
||||
: undefined;
|
||||
const rawPaths = pathsFromArray && pathsFromArray.length > 0
|
||||
? pathsFromArray
|
||||
: ctx.MediaPath?.trim()
|
||||
? [ctx.MediaPath.trim()]
|
||||
: [];
|
||||
|
||||
Reference in New Issue
Block a user