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?