Skip to content
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 @@ -4,6 +4,9 @@ describe('generateMarkdownText', () => {
it.each([
['', null],
[' test message ', 'test message'],
['\uFFFC', ''],
[' \uFFFC ', ''],
['hello\uFFFCworld', 'hello world'],
['https://www.getstream.io', '[https://www.getstream.io](https://www.getstream.io)'],
[
'https://getstream-production.s3-accelerate.amazonaws.com/N336903591601695/33e78ef89e64642862a75c5cca2541eaf6b1c924/trimmedVideos/alert/2_270_881/outputVideo.mp4?AWSAccessKeyId=AKIAVJAW2AD2SQVQCBXV&Expires=1699998768&Signature=zdEMCGzf4Pq++16YkPprvN5NAds=',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export const generateMarkdownText = (text?: string) => {
return null;
}

const normalizedText = text.replace(/\uFFFC/g, ' ');

// Trim the extra spaces from the text.
let resultText = text.trim();
let resultText = normalizedText.trim();

// List of all the links present in the text.
const linkInfos = parseLinksFromText(resultText);
Expand All @@ -24,7 +26,7 @@ export const generateMarkdownText = (text?: string) => {
// Eg: Hi @getstream.io -> Hi @[getstream.io](getstream.io).
const normalRegEx = new RegExp(escapeRegExp(linkInfo.raw), 'g');
const markdown = `[${displayLink}](${linkInfo.url})`;
resultText = text.replace(normalRegEx, markdown);
resultText = normalizedText.replace(normalRegEx, markdown);

// After previous step, in some cases, the mentioned user after `@` might have a link/email so we convert it back to normal raw text.
// Eg: Hi, @[test.user@gmail.com](mailto:test.user@gmail.com) to @test.user@gmail.com.
Expand Down
Loading