sindresorhus / linkify-urls

Linkify URLs in a string
MIT License
163 stars 22 forks source link

Parentheses in URLs break linkifying #28

Open hkdobrev opened 6 years ago

hkdobrev commented 6 years ago

@fregante edit: Issue transferred from refined-github. This issue still happens in v3.1.0

Screenshot 2019-09-07 at 14 57 46

See this line:

The URL contains parentheses which make the anchor cut off the URL in both the href and the visual link producing a wrong URL.

Original valid URL:

https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md
fregante commented 6 years ago

Context: https://github.com/sindresorhus/linkify-urls/commit/aca71b8855c0b13286308119e427184b8158cbed

TL;DR: support was removed because we don't want the final ) inside markdown to be matched, .e.g [github](https://github.com) -> https://github.com)

hkdobrev commented 6 years ago

I think this should be covered by a more sophisticated regex which would make the matching non-greedy for the last parenthesis if it detects a markdown link. This may prove difficult, though and we could work around it by detecting if you're looking at markdown or not.

sindresorhus commented 6 years ago

See: https://github.com/kevva/url-regex/pull/35#issuecomment-342757205 I think this can be fixed now. We need to use the lookbehind operator in the url-regex module and then use it in linkify-urls again.

fregante commented 5 years ago

Blocked by https://bugzilla.mozilla.org/show_bug.cgi?id=1225665

linkify-urls@3 implemented it but we're stuck on v2 because Firefox doesn't support it.

fregante commented 5 years ago

I transferred the issue here because this can't be solved in Refined GitHub