mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
Support for Odata style path params (#5048)
* Support for Odata style path params * Remove test statement * Update packages/bruno-app/src/utils/url/index.spec.js Add more testcases Co-authored-by: sid-bruno <siddharth@usebruno.com> * Performance improvements * Add testcases for odata style url params --------- Co-authored-by: sid-bruno <siddharth@usebruno.com>
This commit is contained in:
@@ -115,16 +115,21 @@ const interpolateVars = (request, envVariables = {}, runtimeVariables = {}, proc
|
||||
throw { message: 'Invalid URL format', originalError: e.message };
|
||||
}
|
||||
|
||||
const paramRegex = /[:](\w+)/g;
|
||||
const interpolatedUrlPath = url.pathname
|
||||
.split('/')
|
||||
.filter((path) => path !== '')
|
||||
.map((path) => {
|
||||
if (path[0] !== ':') {
|
||||
return '/' + path;
|
||||
const matches = path.match(paramRegex);
|
||||
if (matches) {
|
||||
const paramName = matches[0].slice(1); // Remove the : prefix
|
||||
const existingPathParam = request.pathParams.find(param => param.name === paramName);
|
||||
if (!existingPathParam) {
|
||||
return '/' + path;
|
||||
}
|
||||
return '/' + path.replace(':' + paramName, existingPathParam.value);
|
||||
} else {
|
||||
const name = path.slice(1);
|
||||
const existingPathParam = request?.pathParams?.find((param) => param.type === 'path' && param.name === name);
|
||||
return existingPathParam ? '/' + existingPathParam.value : '';
|
||||
return '/' + path;
|
||||
}
|
||||
})
|
||||
.join('');
|
||||
|
||||
Reference in New Issue
Block a user