changeset 242:3ac13a9e593d legit-client

Fix wrong expanded media url
author nanaya <me@nanaya.net>
date Sat, 15 Jul 2023 21:03:39 +0900
parents 4bca1528675e
children bc2f45058c9e
files app/helpers/application_helper.rb
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/helpers/application_helper.rb	Sat Jul 15 17:06:21 2023 +0900
+++ b/app/helpers/application_helper.rb	Sat Jul 15 21:03:39 2023 +0900
@@ -7,7 +7,13 @@
 
   def expand_url(text, urls)
     text.gsub /https?:\/\/t\.co\/[A-Za-z0-9]+/ do |url|
-      urls[url] || url
+      expanded = urls[url]
+
+      case expanded
+        when nil then url
+        when Hash then expanded[:url]
+        else expanded
+      end
     end
   end