Skip to content

Commit bd1df4a

Browse files
authored
fix: render markdown link correctly (regression in 13.2.2) (#2790)
1 parent 93f0a4b commit bd1df4a

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/components/Message/renderText/__tests__/__snapshots__/renderText.test.js.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,22 @@ exports[`renderText handles the special case where user name matches to an e-mai
868868
</div>
869869
`;
870870

871+
exports[`renderText parses correctly text with markdown links 1`] = `
872+
<div>
873+
<p>
874+
a
875+
<a
876+
class="str-chat__message-url-link"
877+
href="https://www.youtube.com/"
878+
rel="nofollow noreferrer noopener"
879+
target="_blank"
880+
>
881+
link
882+
</a>
883+
</p>
884+
</div>
885+
`;
886+
871887
exports[`renderText renders custom mention 1`] = `
872888
<div>
873889
<p>

src/components/Message/renderText/__tests__/renderText.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { u } from 'unist-builder';
44
import { render } from '@testing-library/react';
55
import { htmlToTextPlugin, keepLineBreaksPlugin } from '../remarkPlugins';
66
import { defaultAllowedTagNames, renderText } from '../renderText';
7+
import '@testing-library/jest-dom';
78

89
const strikeThroughText = '~~xxx~~';
910

@@ -14,6 +15,13 @@ describe(`renderText`, () => {
1415
expect(container).toMatchSnapshot();
1516
});
1617

18+
it('parses correctly text with markdown links', () => {
19+
const Markdown = renderText('a [link](https://www.youtube.com/)');
20+
const { container } = render(Markdown);
21+
expect(container).toHaveTextContent('a link');
22+
expect(container).toMatchSnapshot();
23+
});
24+
1725
it('handles the special case where user name matches to an e-mail pattern - 1', () => {
1826
const Markdown = renderText(
1927
'Hello @[email protected], is [email protected] your @primary e-mail?',

src/components/Message/renderText/renderText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const renderText = (
127127
return strippedHref.includes(strippedText) || strippedText.includes(strippedHref);
128128
});
129129

130-
if (noParsingNeeded.length > 0 || linkIsInBlock) return;
130+
if (noParsingNeeded.length > 0 || linkIsInBlock) continue;
131131

132132
try {
133133
// special case for mentions:

0 commit comments

Comments
 (0)