CLI doesn't interpolate params on the URL #2587 (#2588)

Co-authored-by: Fabio Grande <fabio.grande@hdhome.it>
This commit is contained in:
Fabio GRANDE 2024-07-10 08:22:18 +02:00 committed by GitHub
parent 9f76834b2f
commit b2038c7cc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -82,11 +82,11 @@ const interpolateVars = (request, envVars = {}, collectionVariables = {}, proces
request.data = _interpolate(request.data); request.data = _interpolate(request.data);
} }
each(request.params, (param) => { each(request.pathParams, (param) => {
param.value = _interpolate(param.value); param.value = _interpolate(param.value);
}); });
if (request?.params?.length) { if (request?.pathParams?.length) {
let url = request.url; let url = request.url;
if (!url.startsWith('http://') && !url.startsWith('https://')) { if (!url.startsWith('http://') && !url.startsWith('https://')) {
@ -107,7 +107,7 @@ const interpolateVars = (request, envVars = {}, collectionVariables = {}, proces
return '/' + path; return '/' + path;
} else { } else {
const name = path.slice(1); const name = path.slice(1);
const existingPathParam = request.params.find((param) => param.type === 'path' && param.name === name); const existingPathParam = request.pathParams.find((param) => param.type === 'path' && param.name === name);
return existingPathParam ? '/' + existingPathParam.value : ''; return existingPathParam ? '/' + existingPathParam.value : '';
} }
}) })

View File

@ -29,7 +29,8 @@ const prepareRequest = (request, collectionRoot) => {
let axiosRequest = { let axiosRequest = {
method: request.method, method: request.method,
url: request.url, url: request.url,
headers: headers headers: headers,
pathParams: request?.params?.filter((param) => param.type === 'path')
}; };
const collectionAuth = get(collectionRoot, 'request.auth'); const collectionAuth = get(collectionRoot, 'request.auth');