Do not autolink a trailing "!" in a URL #638
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed in another project that uses marked that the text "http://localtunnel.me!" was being turned into a link that incorrectly included the trailing "!".
This PR changes the gfm url regex to explicitly not include a trailing "!".
It also expands the tests for gfm links to test for all the possible ending punctuation that the regex doesn't capture as part of the link as well as a test for no trailing punctuation.
I wasn't sure what the correct behavior is for determining whether a character is part of a link or punctuation. The exclamation point is technically a valid character to use in a url, but so are the closing parens (
")"
) and single and double quote marks, which are also part of the existing url regex. It seems far more likely that a sentence written in markdown would end with a url followed by a "!" than that a url would end with a "!", though.For reference, Rinku, the link-detecting library used by github's markdown gem, allows "?", "!", ".", "," and ":" as trailing punctuation.