


























@@ -162,16 +162,24 @@ describe("detectImageReferences", () => {
162162const ref = expectSingleImageReference(`What does this image show?
163163[Image: source: /Users/tyleryust/Library/Messages/Attachments/IMG_0043.jpeg]`);
164164165-expect(ref?.raw).toBe("/Users/tyleryust/Library/Messages/Attachments/IMG_0043.jpeg");
166-expect(ref?.type).toBe("path");
165+expect(ref).toStrictEqual({
166+raw: "/Users/tyleryust/Library/Messages/Attachments/IMG_0043.jpeg",
167+type: "path",
168+resolved: "/Users/tyleryust/Library/Messages/Attachments/IMG_0043.jpeg",
169+});
167170});
168171169172it("handles complex message attachment paths", () => {
170173const ref = expectSingleImageReference(
171174"[Image: source: /Users/tyleryust/Library/Messages/Attachments/23/03/AA4726EA-DB27-4269-BA56-1436936CC134/5E3E286A-F585-4E5E-9043-5BC2AFAFD81BIMG_0043.jpeg]",
172175);
173176174-expect(ref?.resolved).toContain("IMG_0043.jpeg");
177+expect(ref).toStrictEqual({
178+raw: "/Users/tyleryust/Library/Messages/Attachments/23/03/AA4726EA-DB27-4269-BA56-1436936CC134/5E3E286A-F585-4E5E-9043-5BC2AFAFD81BIMG_0043.jpeg",
179+type: "path",
180+resolved:
181+"/Users/tyleryust/Library/Messages/Attachments/23/03/AA4726EA-DB27-4269-BA56-1436936CC134/5E3E286A-F585-4E5E-9043-5BC2AFAFD81BIMG_0043.jpeg",
182+});
175183});
176184177185it("detects multiple images in [media attached: ...] format", () => {
@@ -219,15 +227,25 @@ Also https://cdn.mysite.com/img.jpg`,
2192271,
220228);
221229222-expect(refs[0]?.raw).toBe("/path/to/real.png");
230+expect(refs).toStrictEqual([
231+{
232+raw: "/path/to/real.png",
233+type: "path",
234+resolved: "/path/to/real.png",
235+},
236+]);
223237});
224238225239it("handles single file format with URL (no index)", () => {
226240const ref =
227241expectSingleImageReference(`[media attached: /cache/photo.jpeg (image/jpeg) | https://example.com/url]
228242what is this?`);
229243230-expect(ref?.resolved).toContain("photo.jpeg");
244+expect(ref).toStrictEqual({
245+raw: "/cache/photo.jpeg",
246+type: "path",
247+resolved: "/cache/photo.jpeg",
248+});
231249});
232250233251it("handles paths with spaces in filename", () => {
@@ -236,8 +254,11 @@ what is this?`);
236254expectSingleImageReference(`[media attached: /Users/test/.openclaw/media/ChatGPT Image Apr 21, 2025.png (image/png) | https://example.com/same.png]
237255what is this?`);
238256239-// Only 1 ref - the local path (example.com URLs are skipped)
240-expect(ref?.resolved).toContain("ChatGPT Image Apr 21, 2025.png");
257+expect(ref).toStrictEqual({
258+raw: "/Users/test/.openclaw/media/ChatGPT Image Apr 21, 2025.png",
259+type: "path",
260+resolved: "/Users/test/.openclaw/media/ChatGPT Image Apr 21, 2025.png",
261+});
241262});
242263243264it("ignores remote-host file URLs", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。