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}; 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