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:
Anton
2025-09-23 09:01:00 +02:00
committed by Bijin A B
parent f24e1e78fe
commit 40b44de294
4 changed files with 181 additions and 28 deletions

View File

@@ -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('');