mirror of
https://github.com/usebruno/bruno.git
synced 2025-03-08 19:41:33 +01:00
interpolate collection vars in Generate Code URL
This commit is contained in:
parent
3c8cb702f5
commit
a23b38a8a0
@ -25,6 +25,13 @@ const GenerateCodeItem = ({ collection, item, onClose }) => {
|
|||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
let collectionVars = {};
|
||||||
|
let collectionRequestVars = get(collection, 'root.request.vars.req', []);
|
||||||
|
collectionRequestVars.forEach((_var) => {
|
||||||
|
if (_var.enabled) {
|
||||||
|
collectionVars[_var.name] = _var.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const requestUrl =
|
const requestUrl =
|
||||||
get(item, 'draft.request.url') !== undefined ? get(item, 'draft.request.url') : get(item, 'request.url');
|
get(item, 'draft.request.url') !== undefined ? get(item, 'draft.request.url') : get(item, 'request.url');
|
||||||
@ -32,6 +39,7 @@ const GenerateCodeItem = ({ collection, item, onClose }) => {
|
|||||||
// interpolate the url
|
// interpolate the url
|
||||||
const interpolatedUrl = interpolateUrl({
|
const interpolatedUrl = interpolateUrl({
|
||||||
url: requestUrl,
|
url: requestUrl,
|
||||||
|
collectionVars,
|
||||||
globalEnvironmentVariables,
|
globalEnvironmentVariables,
|
||||||
envVars,
|
envVars,
|
||||||
runtimeVariables: collection.runtimeVariables,
|
runtimeVariables: collection.runtimeVariables,
|
||||||
|
@ -108,12 +108,13 @@ export const isValidUrl = (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const interpolateUrl = ({ url, globalEnvironmentVariables = {}, envVars, runtimeVariables, processEnvVars }) => {
|
export const interpolateUrl = ({ url, globalEnvironmentVariables = {}, envVars, collectionVars = {}, runtimeVariables, processEnvVars }) => {
|
||||||
if (!url || !url.length || typeof url !== 'string') {
|
if (!url || !url.length || typeof url !== 'string') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return interpolate(url, {
|
return interpolate(url, {
|
||||||
|
...collectionVars,
|
||||||
...globalEnvironmentVariables,
|
...globalEnvironmentVariables,
|
||||||
...envVars,
|
...envVars,
|
||||||
...runtimeVariables,
|
...runtimeVariables,
|
||||||
|
Loading…
Reference in New Issue
Block a user