Skip to content

Commit 97c4f86

Browse files
authored
Merge pull request #1999 from GetStream/release-v9.5.4
v9.5.4
2 parents 6990421 + 903828c commit 97c4f86

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

src/__tests__/__snapshots__/utils.test.js.snap

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`renderText handles the special case where there are pronouns in the name 1`] = `
4+
<p>
5+
hey,
6+
<span
7+
className="str-chat__message-mention"
8+
>
9+
@John (they/them)
10+
</span>
11+
, how are you?
12+
</p>
13+
`;
14+
15+
exports[`renderText handles the special case where there is a backslash in the name 1`] = `
16+
<p>
17+
hey,
18+
<span
19+
className="str-chat__message-mention"
20+
>
21+
@John\\Cena
22+
</span>
23+
, how are you?
24+
</p>
25+
`;
26+
27+
exports[`renderText handles the special case where there is a forward slash in the name 1`] = `
28+
<p>
29+
hey,
30+
<span
31+
className="str-chat__message-mention"
32+
>
33+
@John/Cena
34+
</span>
35+
, how are you?
36+
</p>
37+
`;
38+
339
exports[`renderText handles the special case where user name matches to an e-mail pattern - 1 1`] = `
440
<p>
541
Hello

src/__tests__/utils.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,28 @@ describe(`renderText`, () => {
6060
const tree = renderer.create(Markdown).toJSON();
6161
expect(tree).toMatchSnapshot();
6262
});
63+
64+
it('handles the special case where there are pronouns in the name', () => {
65+
const Markdown = renderText('hey, @John (they/them), how are you?', [
66+
{ id: 'john', name: 'John (they/them)' },
67+
]);
68+
const tree = renderer.create(Markdown).toJSON();
69+
expect(tree).toMatchSnapshot();
70+
});
71+
72+
it('handles the special case where there is a forward slash in the name', () => {
73+
const Markdown = renderText('hey, @John/Cena, how are you?', [
74+
{ id: 'john', name: 'John/Cena' },
75+
]);
76+
const tree = renderer.create(Markdown).toJSON();
77+
expect(tree).toMatchSnapshot();
78+
});
79+
80+
it('handles the special case where there is a backslash in the name', () => {
81+
const Markdown = renderText('hey, @John\\Cena, how are you?', [
82+
{ id: 'john', name: 'John\\Cena' },
83+
]);
84+
const tree = renderer.create(Markdown).toJSON();
85+
expect(tree).toMatchSnapshot();
86+
});
6387
});

src/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export const renderText = <
269269
};
270270

271271
export function escapeRegExp(text: string) {
272-
return text.replace(/[-[\]{}()*+?.,\\^$|#]/g, '\\$&');
272+
return text.replace(/[-[\]{}()*+?.,/\\^$|#]/g, '\\$&');
273273
}
274274

275275
/**

0 commit comments

Comments
 (0)