The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { guestHostImageType, repliesShowImage } from "./guestAttachments.ts"; |
| 4 | |
| 5 | describe("guest host images", () => { |
| 6 | it.each([ |
| 7 | ["", "/w/a.png", "image/png"], |
| 8 | ["", "/w/my shot.jpg", "image/jpeg"], |
| 9 | [".png)", "/w/shot(1).png", "image/png"], |
| 10 | [" ", "/w/shot_1.png", "image/png"], |
| 11 | [" ", "/w/a&b.png", "image/png"], |
| 12 | ["", "/w/café.png", "image/png"], |
| 13 | [" ", "/w/shot.png", "image/png"], |
| 14 | [" ", "/w/shot2.png", "image/png"], |
| 15 | ["![a][r]\n\n[r]: /w/ref.png", "/w/ref.png", "image/png"], |
| 16 | ["", "/w/url form.png", "image/png"], |
| 17 | ["", "C:\\w\\win.png", "image/png"], |
| 18 | ["![a][r]\n\n[r]: C:\\w\\ref.png", "C:/w/ref.png", "image/png"], |
| 19 | [ |
| 20 | '<picture><source media="(prefers-color-scheme: dark)" srcset="/w/dark.png"><img src="/w/light.png"></picture>', |
| 21 | "/w/dark.png", |
| 22 | "image/png", |
| 23 | ], |
| 24 | [ |
| 25 | '<picture><source media="(prefers-color-scheme: dark)" srcset="C:\\w\\dark.png"><img src="C:\\w\\light.png"></picture>', |
| 26 | "C:/w/dark.png", |
| 27 | "image/png", |
| 28 | ], |
| 29 | // Shown as a link, in code, or not at all: the guest sees no image, so none loads. |
| 30 | ["[a](/w/link.png)", "/w/link.png", null], |
| 31 | ["```\n\n```", "/w/code.png", null], |
| 32 | ["``", "/w/span.png", null], |
| 33 | ["<!--  -->", "/w/comment.png", null], |
| 34 | ["", "/a.png", null], |
| 35 | ["", "//host/s/x.png", null], |
| 36 | ["", "\\\\host\\s\\x.png", null], |
| 37 | ["", "/w/a.svg", null], |
| 38 | ["", "/w/a.constructor", null], |
| 39 | ])("%j serves %j as %j", (text, path, type) => { |
| 40 | const served = guestHostImageType(path) !== null && repliesShowImage(path, [{ text }]); |
| 41 | expect(served ? guestHostImageType(path) : null).toBe(type); |
| 42 | }); |
| 43 | }); |