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)
|
def hostname_for_link(path)
|
||||||
begin
|
begin
|
||||||
uri = URI.parse(path)
|
uri = Addressable::URI.parse(path)
|
||||||
rescue URI::InvalidURIError
|
rescue Addressable::URI::InvalidURIError
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
return nil unless uri.host
|
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"))
|
assert_equal("inkbunny.net", hostname_for_link("https://qb.ib.metapix.net"))
|
||||||
end
|
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
|
test "it returns an image if a hostname is found" do
|
||||||
assert_match("furaffinity.net.png", favicon_for_link("https://furaffinity.net"))
|
assert_match("furaffinity.net.png", favicon_for_link("https://furaffinity.net"))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user