mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 14:35:03 +00:00
BRU-3246 fix - added a param check method replacing the param null check (#8157)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user