Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: doubled slashes when parentheses in links #7

Merged
merged 2 commits into from
Apr 14, 2024
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
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
Loading