mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:40:44 +00:00
fix(media): parse lowercase media directives
This commit is contained in:
@@ -125,6 +125,20 @@ describe("createBlockReplyDeliveryHandler", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("parses lowercase media directives in block replies before path normalization", () => {
|
||||
const normalized = normalizeReplyPayloadDirectives({
|
||||
payload: { text: "media: ./report.pdf" },
|
||||
trimLeadingWhitespace: true,
|
||||
parseMode: "auto",
|
||||
});
|
||||
|
||||
expect(normalized.payload).toMatchObject({
|
||||
text: undefined,
|
||||
mediaUrl: "./report.pdf",
|
||||
mediaUrls: ["./report.pdf"],
|
||||
});
|
||||
});
|
||||
|
||||
it("passes normalized media block replies through media path normalization", async () => {
|
||||
const blockReplyPipeline = {
|
||||
enqueue: vi.fn(),
|
||||
|
||||
@@ -26,7 +26,7 @@ export function normalizeReplyPayloadDirectives(params: {
|
||||
parseMode === "always" ||
|
||||
(parseMode === "auto" &&
|
||||
(sourceText.includes("[[") ||
|
||||
sourceText.includes("MEDIA:") ||
|
||||
/media:/i.test(sourceText) ||
|
||||
sourceText.includes(silentToken)));
|
||||
|
||||
const parsed = shouldParse
|
||||
|
||||
@@ -184,7 +184,7 @@ export function splitMediaFromOutput(raw: string): {
|
||||
}
|
||||
|
||||
const trimmedStart = line.trimStart();
|
||||
if (!trimmedStart.startsWith("MEDIA:")) {
|
||||
if (!trimmedStart.toUpperCase().startsWith("MEDIA:")) {
|
||||
keptLines.push(line);
|
||||
pushTextSegment(line);
|
||||
lineOffset += line.length + 1; // +1 for newline
|
||||
|
||||
Reference in New Issue
Block a user