Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

test(gui): stacked/mixed emphasis + surrogate-safe trimming (#197)

Rach Pradhanec467c898ea8
diff --git a/gui/src/components/chat/utils/chatLinks.test.ts b/gui/src/components/chat/utils/chatLinks.test.ts
index 8f2d9d1c..5ebcc19a 100644
--- a/gui/src/components/chat/utils/chatLinks.test.ts
+++ b/gui/src/components/chat/utils/chatLinks.test.ts
@@ -53,4 +53,17 @@ describe("getChatLinkMatches URL vs Markdown delimiters", () => {
value: "http://localhost:3003",
});
});
+
+ test("strips stacked and mixed trailing emphasis delimiters", () => {
+ expect(firstUrl("***https://example.com***")).toBe("https://example.com");
+ expect(firstUrl("~~*https://example.com*~~")).toBe("https://example.com");
+ });
+
+ test("never splits a multi-byte trailing character (surrogate-safe)", () => {
+ // Trimming only removes ASCII markers, so a URL that legitimately ends in a
+ // multi-byte glyph (accents, emoji) is preserved byte-for-byte, never cut
+ // mid-codepoint.
+ expect(firstUrl("**https://example.com/éé**")).toBe("https://example.com/éé");
+ expect(firstUrl("see https://example.com/p\u{1F600}")).toBe("https://example.com/p\u{1F600}");
+ });
});