From a419ac0d7decf48293d9068ec58b3f5112f9c74b Mon Sep 17 00:00:00 2001 From: shaden-pr Date: Sat, 4 Oct 2025 19:15:49 +0100 Subject: [PATCH 1/2] test(formatHashtags): add test to verify only the hashtag part is converted to a link --- front-end/tests/formatHashtag.spec.mjs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 front-end/tests/formatHashtag.spec.mjs diff --git a/front-end/tests/formatHashtag.spec.mjs b/front-end/tests/formatHashtag.spec.mjs new file mode 100644 index 0000000..48eab44 --- /dev/null +++ b/front-end/tests/formatHashtag.spec.mjs @@ -0,0 +1,12 @@ +import { test, expect } from "@playwright/test"; +import { _formatHashtags } from "../components/bloom.mjs"; + +test.describe("_formatHashtag", () => { + test("formats only the hashtag part into a link", () => { + const input = "Let's get some #SwizBiz love!!"; + const result = _formatHashtags(input); + expect(result).toBe( + `Let's get some #SwizBiz love!!` + ); + } ); +}) \ No newline at end of file From d71122a63cad528c8cc83404bfc4e40873cb16f1 Mon Sep 17 00:00:00 2001 From: shaden-pr Date: Sat, 4 Oct 2025 19:17:20 +0100 Subject: [PATCH 2/2] fix(formatHashtags): update regex to match only the hashtag part --- front-end/components/bloom.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front-end/components/bloom.mjs b/front-end/components/bloom.mjs index 0b4166c..bc96ae5 100644 --- a/front-end/components/bloom.mjs +++ b/front-end/components/bloom.mjs @@ -37,7 +37,7 @@ const createBloom = (template, bloom) => { function _formatHashtags(text) { if (!text) return text; return text.replace( - /\B#[^#]+/g, + /#\w+/g, (match) => `${match}` ); } @@ -84,4 +84,4 @@ function _formatTimestamp(timestamp) { } } -export {createBloom}; +export {createBloom ,_formatHashtags};