From 76654c87bd183c2cedf934599f7199c5fc441aa1 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 7 Jun 2026 22:02:33 +0300 Subject: [PATCH] Fix removeMarkdown stripping inline link text --- app/utils/string.test.ts | 6 ++++++ app/utils/strings.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/utils/string.test.ts b/app/utils/string.test.ts index 61c97ac2c..4141951fa 100644 --- a/app/utils/string.test.ts +++ b/app/utils/string.test.ts @@ -74,4 +74,10 @@ describe("removeMarkdown()", () => { test("Strips HTML tags and markdown emphasis", () => { expect(removeMarkdown("
Hello **world**!
")).toBe("Hello world!"); }); + + test("Keeps the link text of inline links", () => { + expect( + removeMarkdown("Check out [the site](https://example.com) today"), + ).toBe("Check out the site today"); + }); }); diff --git a/app/utils/strings.ts b/app/utils/strings.ts index c38d5e409..0fe1de694 100644 --- a/app/utils/strings.ts +++ b/app/utils/strings.ts @@ -113,7 +113,7 @@ export function removeMarkdown(value: string) { // Remove images .replace(/!\[(.*?)\][[(].*?[\])]/g, "") // Remove inline links - .replace(/\[([^\]]*?)\][[(].*?[\])]/g, "$2") + .replace(/\[([^\]]*?)\][[(].*?[\])]/g, "$1") // Remove blockquotes .replace(/^(\n)?\s{0,3}>\s?/gm, "$1") // Remove reference-style links?