Skip to content

Commit 4f85f9f

Browse files
committed
URI.encode has been removed from Ruby 3
Image caching were not working because the Image model silently decided all image were "internal": the URI.encode (aka URI.escape) method does not exist anymore in Ruby 3, which raised an error which where ignored by the "rescue" line. Instead of doing "URI.parse(URI.encode(str))", we are just doing "URI.join(str)", because the join method converts firt the str to RFC3986. As this method does not raise error, the "rescue" part has been removed too.
1 parent 013868c commit 4f85f9f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

app/models/image.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ def register_in_redis
4646
end
4747

4848
def internal_link?
49-
uri = URI.parse(URI.encode link)
49+
uri = URI.join(link)
5050
!uri.host || uri.host == MY_DOMAIN || uri.host == IMG_DOMAIN
51-
rescue
52-
true
5351
end
5452

5553
def blacklisted?
56-
uri = URI.parse(URI.encode link)
54+
uri = URI.join(link)
5755
uri.host =~ /^(10|127|169\.254|192\.168)\./
5856
end
5957

0 commit comments

Comments
 (0)