BRU-3246 fix - added a param check method replacing the param null check (#8157)

This commit is contained in:
Utkarsh
2026-06-16 15:30:04 +05:30
committed by GitHub
parent b73bf9d898
commit 07c7348666
6 changed files with 120 additions and 7 deletions

View File

@@ -2,6 +2,24 @@ const { interpolate } = require('@usebruno/common');
const { each, forOwn, cloneDeep, find } = require('lodash');
const { isFormData } = require('@usebruno/common').utils;
const hasResolvablePathParamValue = (pathParam) => {
if (!pathParam || pathParam.enabled === false) {
return false;
}
const { value } = pathParam;
if (value === null || value === undefined) {
return false;
}
if (typeof value === 'string' && value.trim() === '') {
return false;
}
return true;
};
const isBinaryRequestBody = (data) => Buffer.isBuffer(data) || typeof data?.pipe === 'function';
const getContentType = (headers = {}) => {
@@ -142,7 +160,7 @@ const interpolateVars = (request, envVariables = {}, runtimeVariables = {}, proc
if (path.startsWith(':')) {
const paramName = path.slice(1);
const existingPathParam = request.pathParams.find((param) => param.name === paramName);
if (!existingPathParam) {
if (!hasResolvablePathParamValue(existingPathParam)) {
return '/' + path;
}
return '/' + existingPathParam.value;
@@ -163,7 +181,7 @@ const interpolateVars = (request, envVariables = {}, runtimeVariables = {}, proc
name = name.replace(/^[('"`]+/, '');
if (name) {
const existingPathParam = request.pathParams.find((param) => param.name === name);
if (existingPathParam) {
if (hasResolvablePathParamValue(existingPathParam)) {
result = result.replace(':' + match[1], existingPathParam.value);
}
}