fix handling of empty ref_name parameter string in commits api
when params[:ref_name] is set to "" by passing an empty query parameter to the api it is evaluated as false by the || operator. The use of active support core extensions presence method fixes the original implemantation. https://guides.rubyonrails.org/active_support_core_extensions.html#presence
This commit is contained in:
parent
ea671dec7f
commit
20ac5e6d4b
2 changed files with 6 additions and 1 deletions
5
changelogs/unreleased/fix-commits-api-empty-refname.yml
Normal file
5
changelogs/unreleased/fix-commits-api-empty-refname.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix 500 errors in commits api caused by empty ref_name parameter
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
|
@ -43,7 +43,7 @@ module API
|
|||
path = params[:path]
|
||||
before = params[:until]
|
||||
after = params[:since]
|
||||
ref = params[:ref_name] || user_project.try(:default_branch) || 'master' unless params[:all]
|
||||
ref = params[:ref_name].presence || user_project.try(:default_branch) || 'master' unless params[:all]
|
||||
offset = (params[:page] - 1) * params[:per_page]
|
||||
all = params[:all]
|
||||
with_stats = params[:with_stats]
|
||||
|
|
Loading…
Reference in a new issue