tenderlove / rails_autolink

The auto_link function from Rails
MIT License
588 stars 91 forks source link

Include trailing hyphens in URL #73

Closed ramhoj closed 2 years ago

ramhoj commented 2 years ago

Summary

This PR fixes https://github.com/tenderlove/rails_autolink/issues/52 by including trailing hyphens in URL.

Why

It's valid to have URLs that ends with a -. The behaviour before this PR is to exclude it from the part that is auto linked.

How

We're adding - to the list of characters to not treat as a trailing punctuation.

Before this commit

http://www.rubyonrails.com/foo.cgi?trailing_ampersand=value-

Would generate

<a href=\"http://www.rubyonrails.com/foo.cgi?trailing_ampersand=value\">http://www.rubyonrails.com/foo.cgi?trailing_ampersand=value</a>-

Instead of

<a href=\"http://www.rubyonrails.com/foo.cgi?trailing_ampersand=value-\”>http://www.rubyonrails.com/foo.cgi?trailing_ampersand=value-</a>

Review notes

Note that this branch has failing tests under rails 7. These have been addressed in a seperate PR to make the review effort easier https://github.com/tenderlove/rails_autolink/pull/72. If #72 is merged before this one all tests in this branch should be green under Rails 7.

ramhoj commented 2 years ago

Closing in favor of https://github.com/tenderlove/rails_autolink/pull/65.