Module: OpenURI

Defined in:
lib/berkshelf/api/site_connector/supermarket.rb

Class Method Summary collapse

Class Method Details

.redirectable?(uri1, uri2) ⇒ Boolean

The is a bug in Ruby’s implementation of OpenURI that prevents redirects from HTTP -> HTTPS. That should totally be a valid redirect, so we override that method here and call it a day.

Note: this does NOT permit HTTPS -> HTTP redirects, as that would be a major security hole in the fabric of space-time!

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/berkshelf/api/site_connector/supermarket.rb', line 15

def redirectable?(uri1, uri2)
  a, b = uri1.scheme.downcase, uri2.scheme.downcase

  a == b || (a == 'http' && b == 'https')
end