Skip to content
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

Fix issue with mentions where hash is being displayed on UI #2643

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,20 @@ describe('ContentHighlighter', () => {
expect(wrapper.text()).toContain('Hello, world! 🙂');
});

it('renders content with a user mention', () => {
it('renders content with a user mention (ZERO user ID)', () => {
const wrapper = render({
message: 'Hello, @[John Doe](user:123)!',
});
expect(wrapper.find('.content-highlighter__user-mention').text()).toEqual('John Doe');
});

it('renders content with a user mention (matrix user ID)', () => {
const wrapper = render({
message: 'Hello, @[John Doe](user:@123:zos.zer0.io)!',
});
expect(wrapper.find('.content-highlighter__user-mention').text()).toEqual('John Doe');
});

it('renders content with a different variant', () => {
const wrapper = render({
message: 'Hello, @[John Doe](user:123)!',
Expand Down
5 changes: 2 additions & 3 deletions src/components/content-highlighter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const cn = bemClassName('content-highlighter');

export class ContentHighlighter extends React.Component<Properties> {
renderContent(message) {
const parts = message.split(/(@\[.*?\]\([a-z]+:[A-Za-z0-9_-]+\))/gi);
const parts = message.split(/(@\[.*?\]\([a-z]+:[A-Za-z0-9_@:.-]+\))/gi);
return parts.map((part, index) => {
const match = part.match(/@\[(.*?)\]\(([a-z]+):([A-Za-z0-9_-]+)\)/i);
const match = part.match(/@\[(.*?)\]\(([a-z]+):([A-Za-z0-9_@:.-]+)\)/i);

if (!match) {
return textToPlainEmojis(part);
Expand All @@ -41,7 +41,6 @@ export class ContentHighlighter extends React.Component<Properties> {
</span>
);
}

return part;
});
}
Expand Down