Rails auto_link_urls fix for special characters in url
This one is for Rails 1.1.6. Currently auto_link_urls helper method in text_helper.rb file works well with most of the url’s. It fails to auto link when there are special characters like ~/@/# etc. So here is the quick fix
- Go to text_helper.rb file under your rails folder.
- Replace the url segment line from
([\w]+:?[=?&\/.-]?)* # url segment
to
([\w~,@#\$]+:?[=?&\/.-]?)* # url segment, added support for ~/,/@/#/$ in urls
Just adding special characters to the regex expression works. BTW I tried porting Rails 1.2 text helper code (which looks a lot different than this and it does not work).
February 7, 2008 | Filed Under Ruby/Ruby On Rails
Comments
Leave a Reply