mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-01 18:39:34 +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;
|
||||
}, {});
|
||||
}
|
||||
let collectionVars = {};
|
||||
let collectionRequestVars = get(collection, 'root.request.vars.req', []);
|
||||
collectionRequestVars.forEach((_var) => {
|
||||
if (_var.enabled) {
|
||||
collectionVars[_var.name] = _var.value;
|
||||
}
|
||||
});
|
||||
|
||||
const requestUrl =
|
||||
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
|
||||
const interpolatedUrl = interpolateUrl({
|
||||
url: requestUrl,
|
||||
collectionVars,
|
||||
globalEnvironmentVariables,
|
||||
envVars,
|
||||
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') {
|
||||
return;
|
||||
}
|
||||
|
||||
return interpolate(url, {
|
||||
...collectionVars,
|
||||
...globalEnvironmentVariables,
|
||||
...envVars,
|
||||
...runtimeVariables,
|
||||
|
Loading…
Reference in New Issue
Block a user