Skip to content

Commit

Permalink
fix: doubled slashes when parentheses in links (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-nagornyi authored Apr 14, 2024
1 parent 444ae36 commit f0ac6cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ function escapeSymbols(text, textType = 'text') {
.replace(/\\/g, '\\\\')
case 'link':
return text
.replace(/\\/g, '\\\\')
.replace(/\(/g, '\\(')
.replace(/\)/g, '\\)')
.replace(/\\/g, '\\\\')
default:
return text
.replace(/_/g, '\\_')
Expand Down
6 changes: 6 additions & 0 deletions tests/convert.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ describe('Test convert method', () => {
expect(convert(markdown)).toBe(tgMarkdown);
});

it('Link with parentheses', () => {
const markdown = '[Atlassian](http://atlas()sian.com)';
const tgMarkdown = '[Atlassian](http://atlas\\(\\)sian.com)\n';
expect(convert(markdown)).toBe(tgMarkdown);
});

it('Link in reference style with alt', () => {
const markdown = '[Atlassian]\n\n[atlassian]: http://atlassian.com';
const tgMarkdown = '[Atlassian](http://atlassian.com)\n';
Expand Down

0 comments on commit f0ac6cb

Please sign in to comment.