Repository navigation
Keep the closing bracket out of a link Reddit makes from an address - #124
Merged
Merged
Conversation
A Reddit post that writes a bare address in brackets, as "[https://example.com/a/]", comes from Reddit's page with the closing bracket inside the link, so the link's address ended in an extra "]". When a link in a post or comment holds nothing but its own http or https address as text, the punctuation that ends the address now follows the link as text: a trailing full stop, comma, semicolon, colon, exclamation or question mark, and a closing parenthesis or bracket the address does not open. A link with text of its own keeps its address. Hacker News text goes through the same cleaning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously, a Reddit post that wrote a bare address in brackets, such as
[https://example.com/a/], came out with the closing bracket inside the link. Reddit's own page links the address that way, and the site handler kept the link as it was, so the link's address ended in an extra].After this change,
cleanFragment, which cleans post and comment text for Reddit and Hacker News, trims such links (trimAutolink):.,,,;,:,!or?, and a)or]that the address does not open, move out of the link's address and text and follow the link as text. The example above becomes[<a href="https://example.com/a/">https://example.com/a/</a>].https://en.wikipedia.org/wiki/Go_(game)orhttp://[::1].Verified:
TestCleanFragmentAutolinkcovers the bracketed, parenthesised and trailing-comma cases and the links that must stay as they are. Its four trimming cases and the Reddit case ofTestSiteGoldenfail with the trim removed. The Hacker News golden output is unchanged.