misd-service-development / php-linkify

Converts URLs and email addresses into HTML links
MIT License
112 stars 17 forks source link

Linkify an url ending with a dash fails #29

Open lode opened 6 years ago

lode commented 6 years ago

I have a url, https://medianewsletter.net/lets-give-reader-comments-another-chance-and-for-real-this-time-77506d29856b?source=user_profile---------9---------------- which results in an empty output. If I change it to not end with a dash all works fine.

I can remove the dash from https://github.com/misd-service-development/php-linkify/blob/3481b148806a23b4001712de645247a1a4dcc10a/src/Misd/Linkify/Linkify.php#L161 and it is fixed. However a test will fails which explicitly tests this: https://github.com/misd-service-development/php-linkify/blob/3481b148806a23b4001712de645247a1a4dcc10a/tests/data/url.json#L70-L71 which is assumed to let the dash be excluded from the url.

I don't really understand the requirements here. I could understand if there is a dash in front of the url as well (-http://www.example.com/example-example/-) as it is similar to brackets. But only one at the end should be considered part of the url I would say. E.g. taking into account poorly-written slugify services which don't strip dashes at the end of a slug.

Is it something that can go? Anyone passing by who happens to rely on this behavior?