diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index b4628bff1..fbe79f27d 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -49,7 +49,8 @@ class AttachmentsController < ApplicationController url.gsub!(url.split("/")[-1], '') Rails.logger.info("url===#{url}") Rails.logger.info(filepath) - request_url = [domain, api_url, URI.encode(url), URI.escape(filepath), "?ref=#{URI.escape(ref.split('ref=')[1])}&access_token=#{User.where(admin: true).take&.gitea_token}"].join + ref = ref.blank? ? "" : URI.escape(ref.split('ref=')[1]) + request_url = [domain, api_url, URI.encode(url), URI.escape(filepath), "?ref=#{ref}&access_token=#{User.where(admin: true).take&.gitea_token}"].join Rails.logger.info("request_url===#{request_url}") file = Util.download_file(request_url, tmp_path) filename = filepath