

























@@ -1,6 +1,7 @@
11import fs from "node:fs/promises";
22import os from "node:os";
33import path from "node:path";
4+import { pathToFileURL } from "node:url";
45import { describe, expect, it, vi } from "vitest";
56import { createHostSandboxFsBridge } from "../../test-helpers/host-sandbox-fs-bridge.js";
67import { createUnsafeMountedSandbox } from "../../test-helpers/unsafe-mounted-sandbox.js";
@@ -103,8 +104,10 @@ describe("detectImageReferences", () => {
103104expect(detectImageReferences("[Image: source: /tmp/second.jpg]")).toStrictEqual([
104105{ raw: "/tmp/second.jpg", type: "path", resolved: "/tmp/second.jpg" },
105106]);
106-expect(detectImageReferences("See file:///tmp/third.webp")).toStrictEqual([
107-{ raw: "file:///tmp/third.webp", type: "path", resolved: "/tmp/third.webp" },
107+const thirdPath = path.join(os.tmpdir(), "third.webp");
108+const thirdUrl = pathToFileURL(thirdPath).href;
109+expect(detectImageReferences(`See ${thirdUrl}`)).toStrictEqual([
110+{ raw: thirdUrl, type: "path", resolved: thirdPath },
108111]);
109112expect(detectImageReferences("See ./fourth.jpeg")).toStrictEqual([
110113{ raw: "./fourth.jpeg", type: "path", resolved: "./fourth.jpeg" },
@@ -192,6 +195,18 @@ describe("detectImageReferences", () => {
192195});
193196});
194197198+it("detects Windows drive image paths in plain prompts", () => {
199+const ref = expectSingleImageReference(
200+String.raw`Look at C:\Users\Ada\Pictures\screenshot.png`,
201+);
202+203+expect(ref).toStrictEqual({
204+raw: String.raw`C:\Users\Ada\Pictures\screenshot.png`,
205+type: "path",
206+resolved: String.raw`C:\Users\Ada\Pictures\screenshot.png`,
207+});
208+});
209+195210it("detects [Image: source: ...] format from messaging systems", () => {
196211const ref = expectSingleImageReference(`What does this image show?
197212[Image: source: /Users/tyleryust/Library/Messages/Attachments/IMG_0043.jpeg]`);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。