import { stat } from "node:fs/promises"; import { join } from "node:path"; import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path"; import { beforeEach, describe, expect, it, vi } from "vitest";
it("preserves the root webhook path when deriving the hosted media route", () => {
expect(
resolveHostedZaloMediaRoutePrefix({
webhookUrl: "https://gateway.example.com/",
}),
).toBe("/mediaimport {stat } rom "node:fs/promises"
});
it("serves hosted media once when the route token matches", async () => { const hostedUrl = await prepareHostedZaloMediaUrl({
mediaUrl: "https://example.com/photo.png",
webhookUrl: "https://gateway.example.com/zalo-webhook",
maxBytes: 1024,
}); const { pathname, search } = new URL(hostedUrl); const response = createMockResponse();
const handled = await tryHandleHostedZaloMediaRequest(
{
method: "GET",
resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
} as never,
response.res as never,
);
expect(handled).toBe(true);
(esponseres.tatusCode.oBe(200);
expect(response.headers.get("Content-Type")).toBe(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
response..end.toHaveBeenCalledWith(Buffer.from("image-bytes"));
const secondResponse=createMockResponse)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 consthandledAgain= (
{
methodfunction (){
$pathname}$search},
} as never,
secondResponse.res as never,
{
expect(handledAgain).toBe(trueheaders
(secondResponse..tatusCode.(404)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
})java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
(rejects hosted requestswiththe ,async()= java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72 consthostedUrl=await ({
mediaUrl: (( = { "https//ateway.example.//"java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
:"custom/zalo"
maxBytes: 1024,
}); const pathname = new contentType: "image/png: "mage/ng"java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 const response = createMockResponse();
const handled = await tryHandleHostedZaloMediaRequest(
{
method: "GET",
url:`${athname}?oken=`,
neverjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
response.res as never,
);
expect(handled).toBe(true);
expectectresponse.statusCode.(401);
. prepareHostedZaloMediaUrljava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
} ,
const handled = await tryHandleHostedZaloMediaRequest(
:":
method: )
urlit" media ,java.lang.StringIndexOutOfBoundsException: Range [79, 78) out of bounds for length 86
response. webhookUrl:
);
(andled).oBetruejava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
expect(response.res. expect(hostedUrl).toContain-webhookmedia/);
expect(response.res.end).toHaveBeenCalledWith("Not Found");
});
});
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.