Skip to content

Commit 9c8ac40

Browse files
authored
Merge pull request #2000 from GetStream/develop
v10.7.6
2 parents b28b805 + 3796393 commit 9c8ac40

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
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+
data-user-id="john"
9+
>
10+
@John (they/them)
11+
</span>
12+
, how are you?
13+
</p>
14+
`;
15+
16+
exports[`renderText handles the special case where there is a backslash in the name 1`] = `
17+
<p>
18+
hey,
19+
<span
20+
className="str-chat__message-mention"
21+
data-user-id="john"
22+
>
23+
@John\\Cena
24+
</span>
25+
, how are you?
26+
</p>
27+
`;
28+
29+
exports[`renderText handles the special case where there is a forward slash in the name 1`] = `
30+
<p>
31+
hey,
32+
<span
33+
className="str-chat__message-mention"
34+
data-user-id="john"
35+
>
36+
@John/Cena
37+
</span>
38+
, how are you?
39+
</p>
40+
`;
41+
342
exports[`renderText handles the special case where there's at least one mention and @ symbol at the end 1`] = `
443
<p>
544
<span

src/__tests__/utils.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,28 @@ describe(`renderText`, () => {
8888
const tree = renderer.create(Markdown).toJSON();
8989
expect(tree).toMatchSnapshot();
9090
});
91+
92+
it('handles the special case where there are pronouns in the name', () => {
93+
const Markdown = renderText('hey, @John (they/them), how are you?', [
94+
{ id: 'john', name: 'John (they/them)' },
95+
]);
96+
const tree = renderer.create(Markdown).toJSON();
97+
expect(tree).toMatchSnapshot();
98+
});
99+
100+
it('handles the special case where there is a forward slash in the name', () => {
101+
const Markdown = renderText('hey, @John/Cena, how are you?', [
102+
{ id: 'john', name: 'John/Cena' },
103+
]);
104+
const tree = renderer.create(Markdown).toJSON();
105+
expect(tree).toMatchSnapshot();
106+
});
107+
108+
it('handles the special case where there is a backslash in the name', () => {
109+
const Markdown = renderText('hey, @John\\Cena, how are you?', [
110+
{ id: 'john', name: 'John\\Cena' },
111+
]);
112+
const tree = renderer.create(Markdown).toJSON();
113+
expect(tree).toMatchSnapshot();
114+
});
91115
});

src/utils.tsx

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

333333
export function escapeRegExp(text: string) {
334-
return text.replace(/[-[\]{}()*+?.,\\^$|#]/g, '\\$&');
334+
return text.replace(/[-[\]{}()*+?.,/\\^$|#]/g, '\\$&');
335335
}
336336

337337
/**

0 commit comments

Comments
 (0)