Skip to content

Commit

Permalink
set protocol my merging urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyacheslav Savelyev committed Oct 18, 2017
1 parent 70825fa commit b7dd678
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/oembed/provider_discovery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ def discover_provider(url, options = {})
end

begin
provider_endpoint = URI.parse(provider_endpoint.sub(%r{^//}, 'http://'))
provider_endpoint = URI.parse(provider_endpoint)
# merge the original resource uri with endpoint url
# to set correct protocol in case discoverable
# api endpoint had relative protocol
# https://tools.ietf.org/html/rfc3986#section-5.2
provider_endpoint = uri.merge provider_endpoint
provider_endpoint.query = nil
provider_endpoint = provider_endpoint.to_s
rescue URI::Error
Expand Down

0 comments on commit b7dd678

Please sign in to comment.