Skip to content

Commit

Permalink
Merge pull request #773 from dominictb/fix/45623-link-no-trim
Browse files Browse the repository at this point in the history
fix: no trimming for link name
  • Loading branch information
Gonals authored Aug 9, 2024
2 parents 2421cfc + a6109cb commit 1c71c4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<a href=\"https://www.expensify.com\" data-raw-href=\"https://www.expensify.com\" data-link-variant=\"labeled\" target=\"_blank\" rel=\"noreferrer noopener\"> link </a>';
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) ' +
Expand Down
4 changes: 2 additions & 2 deletions lib/ExpensiMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default class ExpensiMark {
if (!g1.trim()) {
return match;
}
return `<a href="${Str.sanitizeURL(g2)}" data-raw-href="${g2}" data-link-variant="labeled" target="_blank" rel="noreferrer noopener">${g1.trim()}</a>`;
return `<a href="${Str.sanitizeURL(g2)}" data-raw-href="${g2}" data-link-variant="labeled" target="_blank" rel="noreferrer noopener">${g1}</a>`;
},
},

Expand Down Expand Up @@ -298,7 +298,7 @@ export default class ExpensiMark {
{
name: 'reportMentions',

regex: /(?<![^ \n*~_])(#[\p{Ll}0-9-]{1,80})(?![^<]*(?:<\/pre>|<\/code>))/gimu,
regex: /(?<![^ \n*~_])(#[\p{Ll}0-9-]{1,80})(?![^<]*(?:<\/pre>|<\/code>|<\/a>))/gimu,
replacement: '<mention-report>$1</mention-report>',
},

Expand Down

0 comments on commit 1c71c4e

Please sign in to comment.