-
-
Couldn't load subscription status.
- Fork 17
Glasgow | Sheetal kharab | Module Legacy Code | WEEK 1| Hashtag link doesn't work correctly #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Glasgow | Sheetal kharab | Module Legacy Code | WEEK 1| Hashtag link doesn't work correctly #27
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well done:
- Both blooms now generate the correct hashtag URL: /hashtag/SwizBiz
- The frontend hashtag parsing matches the backend's hashtag storage logic
- All hashtag links will work correctly regardless of punctuation or position in the text
- Proper URL encoding prevents any special character issues
.
|
|
||
|
|
||
| def add_bloom(*, sender: User, content: str) -> Bloom: | ||
| if len(content) > 280: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well done limiting content length in front end as well
|
|
||
| function _formatHashtags(text) { | ||
| if (!text) return text; | ||
| // special character in hashtag convert into url friendly format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good comment
| return text.replace( | ||
| /\B#[^#]+/g, | ||
| (match) => `<a href="/hashtag/${match.slice(1)}">${match}</a>` | ||
| /\B#(\w+)/g, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch:
- /\B#(\w+)/g - Only captures word characters (letters, digits, underscore)
- Uses capturing group to extract just the tag name
- encodeURIComponent(tag) - Properly encodes for URLs
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.