diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 200ad55e3..6db403265 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -42,8 +42,9 @@ class AttachmentsController < ApplicationController domain = GiteaService.gitea_config[:domain] api_url = GiteaService.gitea_config[:base_url] url = ("/repos"+url.split(base_url + "/api")[1]) - filepath, ref = url.split("/")[-1].split("?") - url.gsub!(url.split("/")[-1], '') + ref = url.split("?")[1] + filepath = url.split("?")[0].split("/")[-1] + url.gsub!(filepath+"?"+ref, '') # Rails.logger.info("url===#{url}") Rails.logger.info(filepath) ref = ref.blank? ? "" : URI.escape(ref.split('ref=')[1])