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

Underscore not detected at end of link #2757

Closed
Dsinghbailey opened this issue Mar 16, 2023 · 3 comments
Closed

Underscore not detected at end of link #2757

Dsinghbailey opened this issue Mar 16, 2023 · 3 comments

Comments

@Dsinghbailey
Copy link

Marked version:
^4.2.12

Describe the bug
Marked doesn't detect ending underscores in links

https://twitter.com/madebynelson_ is detected as "https://twitter.com/madebynelson"

To Reproduce
Steps to reproduce the behavior:
marked.parse(DOMPurify.sanitize('https://twitter.com/madebynelson_')

Expected behavior
I expect link to render with ending underscore, especially if there are no previous underscores

@UziTech
Copy link
Member

UziTech commented Mar 17, 2023

This is the way it is supposed to work to follow the GFM spec:

Trailing punctuation (specifically, ?, !, ., ,, :, *, _, and ~) will not be considered part of the autolink, though they may be included in the interior of the link

@UziTech
Copy link
Member

UziTech commented Mar 17, 2023

And just so you know, you should sanitize the output of marked not the input.

- marked.parse(DOMPurify.sanitize('https://twitter.com/madebynelson_'))
+ DOMPurify.sanitize(marked.parse('https://twitter.com/madebynelson_'))

@Dsinghbailey
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants