Skip to content

Commit

Permalink
Allow to parse parameters with multiple values
Browse files Browse the repository at this point in the history
Allow to receive multiple values for the parameter "file" for the
following source package commands: diff, linkdiff and servicediff.
  • Loading branch information
eduardoj committed Feb 3, 2023
1 parent c45c75e commit e70f242
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/api/app/controllers/source_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class SourceController < ApplicationController

skip_before_action :extract_user, only: [:lastevents_public, :global_command_orderkiwirepos, :global_command_triggerscmsync]
skip_before_action :require_login, only: [:lastevents_public, :global_command_orderkiwirepos, :global_command_triggerscmsync]
# we use an array for the "file" parameter for: package_command_diff, package_command_linkdiff and package_command_servicediff
skip_before_action :validate_params, only: [:package_command]

before_action :require_valid_project_name, except: [:index, :lastevents, :lastevents_public,
:global_command_orderkiwirepos, :global_command_branch,
Expand Down
6 changes: 4 additions & 2 deletions src/api/app/lib/backend/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ def self.build_query_from_hash(hash, key_list = nil)

if hash[key].nil?
# just a boolean argument ?
[hash[key]].flat_map { key }.join('&')
key
elsif hash[key].is_a?(Array)
hash[key].map { |value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
else
[hash[key]].flat_map { "#{key}=#{CGI.escape(hash[key].to_s)}" }.join('&')
"#{key}=#{CGI.escape(hash[key].to_s)}"
end
end
query.empty? ? '' : "?#{query.compact.join('&')}"
Expand Down

0 comments on commit e70f242

Please sign in to comment.