fix: Remove duplicate / character on the proxy route (#10404)

The proxy method adds an extra slash even if the route param has the
character. It’s challenging to check the expected format on each route.
The simplest solution is to check if the route param begins with a
slash, and if not, append one.

NB: The existing tests are sufficient to cover this case. There’s no
need for an additional test to specifically test this.
This commit is contained in:
Pranav
2024-11-12 10:38:29 -08:00
committed by GitHub
parent 97d7b9d754
commit 7dc0eba48a

View File

@@ -18,11 +18,11 @@ class Api::V1::Accounts::Integrations::CaptainController < Api::V1::Accounts::Ba
end end
def request_path def request_path
if params[:route] == '/sessions/profile' request_route = with_leading_hash_on_route(params[:route])
'api/sessions/profile'
else return 'api/sessions/profile' if request_route == '/sessions/profile'
"api/accounts/#{hook.settings['account_id']}/#{params[:route]}"
end "api/accounts/#{hook.settings['account_id']}#{request_route}"
end end
def request_url def request_url
@@ -41,6 +41,12 @@ class Api::V1::Accounts::Integrations::CaptainController < Api::V1::Accounts::Ba
method method
end end
def with_leading_hash_on_route(request_route)
return '' if request_route.blank?
request_route.start_with?('/') ? request_route : "/#{request_route}"
end
def permitted_params def permitted_params
params.permit(:method, :route, body: {}) params.permit(:method, :route, body: {})
end end