lib/autolink.rb in twitter-text-1.4.14 vs lib/autolink.rb in twitter-text-1.4.15
- old
+ new
@@ -150,10 +150,17 @@
end
html_attrs = html_attrs_for_options(options)
Twitter::Rewriter.rewrite_urls(text) do |url|
+ # In the case of t.co URLs, don't allow additional path characters
+ after = ""
+ if url =~ Twitter::Regex[:valid_tco_url]
+ url = $&
+ after = $'
+ end
+
href = if options[:link_url_block]
options.delete(:link_url_block).call(url)
else
html_escape(url)
end
@@ -161,10 +168,10 @@
display_url = url
if url_entities[url] && url_entities[url][:display_url]
display_url = url_entities[url][:display_url]
end
- %(<a href="#{href}"#{html_attrs}>#{html_escape(display_url)}</a>)
+ %(<a href="#{href}"#{html_attrs}>#{html_escape(display_url)}</a>#{after})
end
end
private