From f1b84e09c3d028706b1ad1f2f45bdf3504860ea1 Mon Sep 17 00:00:00 2001 From: Abhishek S Lal Date: Fri, 27 Mar 2026 20:03:00 +0530 Subject: [PATCH] fix: update regex for path parameter parsing to handle alphanumeric and underscore characters (#7388) --- packages/bruno-app/src/utils/url/index.js | 4 ++-- packages/bruno-app/src/utils/url/index.spec.js | 14 ++++++++++++++ packages/bruno-cli/src/runner/interpolate-vars.js | 2 +- .../src/ipc/network/interpolate-vars.js | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/bruno-app/src/utils/url/index.js b/packages/bruno-app/src/utils/url/index.js index 335351422..710186127 100644 --- a/packages/bruno-app/src/utils/url/index.js +++ b/packages/bruno-app/src/utils/url/index.js @@ -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))) { diff --git a/packages/bruno-app/src/utils/url/index.spec.js b/packages/bruno-app/src/utils/url/index.spec.js index cd546cc95..88c215f71 100644 --- a/packages/bruno-app/src/utils/url/index.spec.js +++ b/packages/bruno-app/src/utils/url/index.spec.js @@ -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'); diff --git a/packages/bruno-cli/src/runner/interpolate-vars.js b/packages/bruno-cli/src/runner/interpolate-vars.js index 7e5cae14c..32bc0d2e4 100644 --- a/packages/bruno-cli/src/runner/interpolate-vars.js +++ b/packages/bruno-cli/src/runner/interpolate-vars.js @@ -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))) { diff --git a/packages/bruno-electron/src/ipc/network/interpolate-vars.js b/packages/bruno-electron/src/ipc/network/interpolate-vars.js index 8494acf0b..d0ad03876 100644 --- a/packages/bruno-electron/src/ipc/network/interpolate-vars.js +++ b/packages/bruno-electron/src/ipc/network/interpolate-vars.js @@ -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))) {