forked from e621ng/e621ng
[Posts] Use addressable for source parsing
Fixes no icons for links with square brackets
This commit is contained in:
parent
aeb2076b80
commit
2e140a5607
@ -173,8 +173,8 @@ module LinkHelper
|
||||
|
||||
def hostname_for_link(path)
|
||||
begin
|
||||
uri = URI.parse(path)
|
||||
rescue URI::InvalidURIError
|
||||
uri = Addressable::URI.parse(path)
|
||||
rescue Addressable::URI::InvalidURIError
|
||||
return nil
|
||||
end
|
||||
return nil unless uri.host
|
||||
|
@ -31,6 +31,10 @@ class LinkHelperTest < ActionView::TestCase
|
||||
assert_equal("inkbunny.net", hostname_for_link("https://qb.ib.metapix.net"))
|
||||
end
|
||||
|
||||
test "for a link that contains square brackets" do
|
||||
assert_equal("furaffinity.net", hostname_for_link("https://d.furaffinity.net/square_[brackets].png"))
|
||||
end
|
||||
|
||||
test "it returns an image if a hostname is found" do
|
||||
assert_match("furaffinity.net.png", favicon_for_link("https://furaffinity.net"))
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user