about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2021-02-21 13:10:39 -0600
committerStarfall <us@starfall.systems>2021-02-21 13:10:39 -0600
commit86de4ec5559164a49b2790d774f8bba5af02c64f (patch)
tree804ac22f8ea54824346d336f9fe7664e205719ff /app/services
parent3693000bf6a94219e3cc4a29a6cb4ac51b78cf2a (diff)
parent8792128f38e19b0d7882468a4f1f9362b98793a0 (diff)
Merge remote-tracking branch 'glitchsoc/main' into main
Diffstat (limited to 'app/services')
-rw-r--r--app/services/fetch_oembed_service.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/services/fetch_oembed_service.rb b/app/services/fetch_oembed_service.rb
index 67e33875c..60be9b9dc 100644
--- a/app/services/fetch_oembed_service.rb
+++ b/app/services/fetch_oembed_service.rb
@@ -38,7 +38,17 @@ class FetchOEmbedService
 
     return if @endpoint_url.blank?
 
-    @endpoint_url = (Addressable::URI.parse(@url) + @endpoint_url).to_s
+    @endpoint_url = begin
+      base_url = Addressable::URI.parse(@url)
+
+      # If the OEmbed endpoint is given as http but the URL we opened
+      # was served over https, we can assume OEmbed will be available
+      # through https as well
+
+      (base_url + @endpoint_url).tap do |absolute_url|
+        absolute_url.scheme = base_url.scheme if base_url.scheme == 'https'
+      end.to_s
+    end
 
     cache_endpoint!
   rescue Addressable::URI::InvalidURIError