Skip to content

West Midlands | 26 March SDC | Iswat Bello | Sprint 1 | Purple Forest/bug report/Hashtag link doesn't work#211

Open
Iswanna wants to merge 1 commit into
CodeYourFuture:mainfrom
Iswanna:Purple-Forest/bug-report/Hashtag-link-doesnt-work
Open

West Midlands | 26 March SDC | Iswat Bello | Sprint 1 | Purple Forest/bug report/Hashtag link doesn't work#211
Iswanna wants to merge 1 commit into
CodeYourFuture:mainfrom
Iswanna:Purple-Forest/bug-report/Hashtag-link-doesnt-work

Conversation

@Iswanna

@Iswanna Iswanna commented Jun 11, 2026

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

This PR fixes a bug where hashtags located in the middle of a sentence were incorrectly linked because the application captured trailing spaces and punctuation as part of the hashtag name.

1. Reproduction Steps

To confirm the bug, I performed the following:

  1. Loaded the database with sample data.
  2. From the UI, I located the bloom from user Swiz: "Let's get some #SwizBiz love!!"
  3. Clicked on the #SwizBiz link.
  4. Observation: The page loaded but was completely empty.
  5. Network Trace: I checked the Chrome DevTools Network tab and found that the request URL was: http://localhost:3000/hashtag/SwizBiz%2520love!!.
  6. Diagnosis: The application was trying to search for a hashtag that included the trailing space and the next word ("love!!").

2. The Problem

Hashtags located in the middle of a sentence were being "over-captured." Because the link included spaces and punctuation, the backend could not find a match in the database, resulting in an empty results page.

3. The Discovery

I investigated frontend/components/bloom.mjs and found the _formatHashtags function.

  • The Bug: It used a Regex pattern: /\B#[^#]+/g.
  • The Logic Error: The [^#]+ part tells the browser to "capture every character that is NOT a hash." Since spaces and exclamation marks are not hashes, the browser kept grabbing them until the end of the string.

4. The Fix

I updated the Regex pattern in frontend/components/bloom.mjs to:
/\B#\w+/g

5. The Logic

By switching to \w+, the Regex is now restricted to "Word Characters" (letters, numbers, and underscores).

  • Result: As soon as the browser hits a space, a period, or an exclamation mark, it realizes that character is not a "word character" and stops the hashtag capture immediately.

6. Verification

After the fix, I returned to the timeline and clicked the same link.

  • Observation: The search now correctly displays all blooms containing #SwizBiz.
  • Network Trace: Confirmed the request is now clean: /hashtag/SwizBiz.

Restrict hashtag parsing in bloom.mjs from /\B#[^#]+/g to /\B#[\w]+/g so hashtags include only letters/digits/underscore and exclude punctuation or spaces.
@Iswanna Iswanna added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Legacy-Code The name of the module. labels Jun 11, 2026
@nedssoft nedssoft added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jun 24, 2026

@nedssoft nedssoft left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a beautiful piece of debugging, Iswat. 👏 Tracing the empty page back to the over-encoded URL (%2520), realising [^#]+ was greedily swallowing the trailing space and punctuation, then switching to \w+ so it stops at the first non-word character — that's a really clear grasp of how regex character classes work. Verified cleanly, too. Lovely work — nothing to change here.

@nedssoft nedssoft added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jun 24, 2026
@Iswanna

Iswanna commented Jun 25, 2026

Copy link
Copy Markdown
Author

This is a beautiful piece of debugging, Iswat. 👏 Tracing the empty page back to the over-encoded URL (%2520), realising [^#]+ was greedily swallowing the trailing space and punctuation, then switching to \w+ so it stops at the first non-word character — that's a really clear grasp of how regex character classes work. Verified cleanly, too. Lovely work — nothing to change here.

Thank you so much @nedssoft, for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Legacy-Code The name of the module. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants