mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-25 13:45:52 +00:00
fix: update regex for path parameter parsing to handle alphanumeric and underscore characters (#7388)
This commit is contained in:
@@ -53,7 +53,7 @@ export const parsePathParams = (url) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const paramRegex = /[:](\w+)/g;
|
||||
const paramRegex = /[:]([a-zA-Z_]\w*)/g;
|
||||
let match;
|
||||
while ((match = paramRegex.exec(segment))) {
|
||||
if (!match[1]) continue;
|
||||
@@ -131,7 +131,7 @@ export const interpolateUrlPathParams = (url, params, variables = {}, options =
|
||||
return segment;
|
||||
}
|
||||
|
||||
const regex = /[:](\w+)/g;
|
||||
const regex = /[:]([a-zA-Z_]\w*)/g;
|
||||
let match;
|
||||
let result = segment;
|
||||
while ((match = regex.exec(segment))) {
|
||||
|
||||
@@ -156,6 +156,20 @@ describe('Url Utils - parsePathParams', () => {
|
||||
expect(params).toEqual([]);
|
||||
});
|
||||
|
||||
it('should NOT treat colons in datetime values as path parameters', () => {
|
||||
const params = parsePathParams(
|
||||
'https://api10.successfactors.com/odata/v2/EmpJob(seqNumber=1L,startDate=datetime\'2021-08-29T00:00:00\',userId=\'213668\')'
|
||||
);
|
||||
expect(params).toEqual([]);
|
||||
});
|
||||
|
||||
it('should still parse named path params in OData segments with datetime values', () => {
|
||||
const params = parsePathParams(
|
||||
'https://example.com/odata/EmpJob(startDate=datetime\'2021-08-29T00:00:00\',userId=:userId)'
|
||||
);
|
||||
expect(params).toEqual([{ name: 'userId', value: '' }]);
|
||||
});
|
||||
|
||||
it('should NOT treat embedded colons as path parameters (regression fix)', () => {
|
||||
// This test case reproduces the bug reported in issue #5805
|
||||
const params = parsePathParams('/start/1:2:AHLS-HASD/form');
|
||||
|
||||
@@ -147,7 +147,7 @@ const interpolateVars = (request, envVariables = {}, runtimeVariables = {}, proc
|
||||
// 2. EntitySet(Key1=value1,Key2=value2)
|
||||
// 3. Function(param=value)
|
||||
if (/^[A-Za-z0-9_.-]+\([^)]*\)$/.test(path)) {
|
||||
const paramRegex = /[:](\w+)/g;
|
||||
const paramRegex = /[:]([a-zA-Z_]\w*)/g;
|
||||
let match;
|
||||
let result = path;
|
||||
while ((match = paramRegex.exec(path))) {
|
||||
|
||||
@@ -184,7 +184,7 @@ const interpolateVars = (request, envVariables = {}, runtimeVariables = {}, proc
|
||||
// 2. EntitySet(Key1=value1,Key2=value2)
|
||||
// 3. Function(param=value)
|
||||
if (/^[A-Za-z0-9_.-]+\([^)]*\)$/.test(path)) {
|
||||
const paramRegex = /[:](\w+)/g;
|
||||
const paramRegex = /[:]([a-zA-Z_]\w*)/g;
|
||||
let match;
|
||||
let result = path;
|
||||
while ((match = paramRegex.exec(path))) {
|
||||
|
||||
Reference in New Issue
Block a user