
























@@ -127,15 +127,41 @@ describe("detectImageReferences", () => {
127127});
128128129129it("deduplicates repeated image references", () => {
130-expectImageReferenceCount("Look at /path/image.png and also /path/image.png again", 1);
130+expect(
131+detectImageReferences("Look at /path/image.png and also /path/image.png again"),
132+).toStrictEqual([
133+{
134+raw: "/path/image.png",
135+type: "path",
136+resolved: "/path/image.png",
137+},
138+]);
131139});
132140133141it("dedupe casing follows host filesystem conventions", () => {
142+const prompt = "Look at /tmp/Image.png and /tmp/image.png";
134143if (process.platform === "win32") {
135-expectImageReferenceCount("Look at /tmp/Image.png and /tmp/image.png", 1);
144+expect(detectImageReferences(prompt)).toStrictEqual([
145+{
146+raw: "/tmp/Image.png",
147+type: "path",
148+resolved: "/tmp/Image.png",
149+},
150+]);
136151return;
137152}
138-expectImageReferenceCount("Look at /tmp/Image.png and /tmp/image.png", 2);
153+expect(detectImageReferences(prompt)).toStrictEqual([
154+{
155+raw: "/tmp/Image.png",
156+type: "path",
157+resolved: "/tmp/Image.png",
158+},
159+{
160+raw: "/tmp/image.png",
161+type: "path",
162+resolved: "/tmp/image.png",
163+},
164+]);
139165});
140166141167it("returns empty array when no images found", () => {
@@ -149,13 +175,21 @@ describe("detectImageReferences", () => {
149175it("handles paths inside quotes (without spaces)", () => {
150176const ref = expectSingleImageReference('The file is at "/path/to/image.png"');
151177152-expect(ref?.raw).toBe("/path/to/image.png");
178+expect(ref).toStrictEqual({
179+raw: "/path/to/image.png",
180+type: "path",
181+resolved: "/path/to/image.png",
182+});
153183});
154184155185it("handles paths in parentheses", () => {
156186const ref = expectSingleImageReference("See the image (./screenshot.png) for details");
157187158-expect(ref?.raw).toBe("./screenshot.png");
188+expect(ref).toStrictEqual({
189+raw: "./screenshot.png",
190+type: "path",
191+resolved: "./screenshot.png",
192+});
159193});
160194161195it("detects [Image: source: ...] format from messaging systems", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。