From 4c2c3d17e263e402d12f9aa41761ae104b3230cc Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Tue, 12 Jan 2021 15:47:04 +0800 Subject: [PATCH] FIX base and head params problem for compare api --- app/controllers/compare_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/compare_controller.rb b/app/controllers/compare_controller.rb index e5e61598e..0918b9d3b 100644 --- a/app/controllers/compare_controller.rb +++ b/app/controllers/compare_controller.rb @@ -6,9 +6,9 @@ class CompareController < ApplicationController end def show - base_ref = Addressable::URI.unescape(params[:base]) - @ref = head_ref = Addressable::URI.unescape(params[:head]&.split('.json')[0]) - @compare_result = Gitea::Repository::Commits::CompareService.call(@owner.login, @project.identifier, base_ref, head_ref) + base = Addressable::URI.unescape(params[:base]) + head = params[:head].include?('json') ? params[:head]&.split('.json')[0] : params[:head] + @compare_result = Gitea::Repository::Commits::CompareService.call(@owner.login, @project.identifier, head, base) # render json: @compare_result end