diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js
index ab3cd854..0b03ec1c 100644
--- a/__tests__/ExpensiMark-HTML-test.js
+++ b/__tests__/ExpensiMark-HTML-test.js
@@ -1040,6 +1040,12 @@ test('Test markdown and url links with inconsistent starting and closing parens'
expect(parser.replace(testString)).toBe(resultString);
});
+test('Test link: Keep spaces at both end for shouldKeepRawInput=true', () => {
+ const testString = '[ link ](https://www.expensify.com)';
+ const resultString = ' link ';
+ expect(parser.replace(testString, {shouldKeepRawInput: true})).toBe(resultString);
+});
+
test('Test autolink replacement to avoid parsing nested links', () => {
const testString =
'[click google.com *here*](google.com) ' +
diff --git a/lib/ExpensiMark.ts b/lib/ExpensiMark.ts
index 34b437ed..8b97487c 100644
--- a/lib/ExpensiMark.ts
+++ b/lib/ExpensiMark.ts
@@ -267,7 +267,7 @@ export default class ExpensiMark {
if (!g1.trim()) {
return match;
}
- return `${g1.trim()}`;
+ return `${g1}`;
},
},
@@ -298,7 +298,7 @@ export default class ExpensiMark {
{
name: 'reportMentions',
- regex: /(?|<\/code>))/gimu,
+ regex: /(?|<\/code>|<\/a>))/gimu,
replacement: '$1',
},