gottfrois / link_thumbnailer

Ruby gem that fetches images and metadata from a given URL. Much like popular social website with link preview.
MIT License
512 stars 106 forks source link

Warning: URI.escape is obsolete #143

Closed srijan-kapoor closed 1 year ago

srijan-kapoor commented 4 years ago

.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/image_info-1.2.0/lib/image_info/image.rb:10: warning: URI.escape is obsolete

I'm seeing this warning each time I trigger the link-thumbnailer. Any ideas on how this can be fixed or suppressed?

begin 
response = LinkThumbnailer.generate(url)
rescue LinkThumbnailer::Exceptions => e
   puts "Rescused: #{e}"
end
gottfrois commented 4 years ago

Thanks for reporting this issue. It was interesting to find out why this is popping up. I've found some explanations here https://docs.knapsackpro.com/2020/uri-escape-is-obsolete-percent-encoding-your-query-string

I'll see what I can do on the image_info gem.

srijan-kapoor commented 4 years ago

Yeah that's the only helpful explanation I came across when I looked it up.

Thank you for considering it.

srijan-kapoor commented 4 years ago

I have tried to percent-encode my query string - to escape these warnings - and pass it as

query_url = https%3A%2F%2Ft.co%2FMnKEe0XpsY
LinkThumbnailer.generate(query_url)

but I see this returned

Rescued: LinkThumbnailer::BadUriFormat

Just curious if it doesn't support the encoded url string or if I'm missing something here. Thanks!

gottfrois commented 4 years ago

The gem will attempt to parse the given url using the following code:

::URI.parse(url.to_s)

and consider valid url if url.is_a?(::URI::HTTP)

gottfrois commented 1 year ago

Looks like it's fixed on latest image info gem version