FIX: URLs containing two # would fail to work

Some URLs in browsers are non compliant and contain twos `#` this commit adds
special handling for this edge case by auto encoding any fragments containing `#`
This commit is contained in:
Sam
2018-12-11 18:03:13 +11:00
parent bb4ef644bf
commit 671469bcc7
6 changed files with 47 additions and 26 deletions

View File

@@ -117,11 +117,7 @@ SQL
PrettyText
.extract_links(post.cooked)
.map do |u|
uri = begin
URI.parse(u.url)
rescue URI::Error
end
uri = UrlHelper.relaxed_parse(u.url)
[u, uri]
end
.reject { |_, p| p.nil? || "mailto".freeze == p.scheme }

View File

@@ -15,11 +15,7 @@ class TopicLinkClick < ActiveRecord::Base
url = args[:url][0...TopicLink.max_url_length]
return nil if url.blank?
uri = begin
URI.parse(url)
rescue URI::Error
end
uri = UrlHelper.relaxed_parse(url)
urls = Set.new
urls << url
if url =~ /^http/