























@@ -97,10 +97,18 @@ describe("detectImageReferences", () => {
9797});
98989999it("does not leak parser state between calls", () => {
100-expectSingleImageReference("[media attached: /tmp/first.png (image/png)]");
101-expectSingleImageReference("[Image: source: /tmp/second.jpg]");
102-expectSingleImageReference("See file:///tmp/third.webp");
103-expectSingleImageReference("See ./fourth.jpeg");
100+expect(detectImageReferences("[media attached: /tmp/first.png (image/png)]")).toStrictEqual([
101+{ raw: "/tmp/first.png", type: "path", resolved: "/tmp/first.png" },
102+]);
103+expect(detectImageReferences("[Image: source: /tmp/second.jpg]")).toStrictEqual([
104+{ raw: "/tmp/second.jpg", type: "path", resolved: "/tmp/second.jpg" },
105+]);
106+expect(detectImageReferences("See file:///tmp/third.webp")).toStrictEqual([
107+{ raw: "file:///tmp/third.webp", type: "path", resolved: "/tmp/third.webp" },
108+]);
109+expect(detectImageReferences("See ./fourth.jpeg")).toStrictEqual([
110+{ raw: "./fourth.jpeg", type: "path", resolved: "./fourth.jpeg" },
111+]);
104112});
105113106114it("handles various image extensions", () => {
@@ -176,8 +184,18 @@ what about these images?`,
1761842,
177185);
178186179-expect(refs[0]?.resolved).toContain("IMG_6430.jpeg");
180-expect(refs[1]?.resolved).toContain("IMG_6431.jpeg");
187+expect(refs).toStrictEqual([
188+{
189+raw: "/Users/tyleryust/.openclaw/media/IMG_6430.jpeg",
190+type: "path",
191+resolved: "/Users/tyleryust/.openclaw/media/IMG_6430.jpeg",
192+},
193+{
194+raw: "/Users/tyleryust/.openclaw/media/IMG_6431.jpeg",
195+type: "path",
196+resolved: "/Users/tyleryust/.openclaw/media/IMG_6431.jpeg",
197+},
198+]);
181199});
182200183201it("does not double-count path and url in same bracket", () => {
@@ -186,7 +204,11 @@ what about these images?`,
186204"[media attached: /cache/IMG_6430.jpeg (image/jpeg) | /cache/IMG_6430.jpeg]",
187205);
188206189-expect(ref?.resolved).toContain("IMG_6430.jpeg");
207+expect(ref).toStrictEqual({
208+raw: "/cache/IMG_6430.jpeg",
209+type: "path",
210+resolved: "/cache/IMG_6430.jpeg",
211+});
190212});
191213192214it("ignores remote URLs entirely (local-only)", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。