Spaces:
Running
Running
Download apps/web/src/bildUrl.test.ts from Bryan-HSLU/FP_POC: direct link, hf CLI and curl.
- Browser
- Download file 832 Bytes
-
https://huggingface.co/spaces/Bryan-HSLU/FP_POC/resolve/main/apps/web/src/bildUrl.test.ts
- Command line
-
hf download hf://spaces/Bryan-HSLU/FP_POC/apps/web/src/bildUrl.test.ts
-
curl -L -o bildUrl.test.ts https://huggingface.co/spaces/Bryan-HSLU/FP_POC/resolve/main/apps/web/src/bildUrl.test.ts
832 Bytes
| import { describe, expect, it } from "vitest"; | |
| import { bildUrl } from "./bildUrl"; | |
| describe("bildUrl", () => { | |
| it("kodiert Leerzeichen als %20", () => { | |
| expect(bildUrl("Bild Nasszelle.jpg")).toBe("/bilder/Bild%20Nasszelle.jpg"); | |
| }); | |
| it("lässt Klammern unkodiert (encodeURIComponent-Ausnahmezeichen)", () => { | |
| // encodeURIComponent kodiert "(" und ")" bewusst nicht – nur Leerzeichen davor. | |
| expect(bildUrl("Bild Nasszelle (1).jpg")).toBe("/bilder/Bild%20Nasszelle%20(1).jpg"); | |
| }); | |
| it("kodiert Umlaute", () => { | |
| expect(bildUrl("Bäder Übersicht.jpg")).toBe("/bilder/B%C3%A4der%20%C3%9Cbersicht.jpg"); | |
| }); | |
| it("kodiert jedes Pfadsegment einzeln, der Schrägstrich bleibt Trenner", () => { | |
| expect(bildUrl("bad/Bild Nasszelle (1).jpg")).toBe("/bilder/bad/Bild%20Nasszelle%20(1).jpg"); | |
| }); | |
| }); | |