mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
feat: support for variables in url
This commit is contained in:
@@ -57,10 +57,24 @@ const createPostData = (body) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const createUrl = (request) => {
|
||||||
|
let url = request.url;
|
||||||
|
const variablePattern = /\{\{([^}]+)\}\}/g;
|
||||||
|
const variables = request.url.match(variablePattern);
|
||||||
|
if (variables) {
|
||||||
|
variables.forEach((variable) => {
|
||||||
|
const variableName = variable.replaceAll('{', '').replaceAll('}', '');
|
||||||
|
const variableValue = request.vars.req.find((v) => v.name === variableName).value;
|
||||||
|
url = url.replace(variable, variableValue);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
export const buildHarRequest = (request) => {
|
export const buildHarRequest = (request) => {
|
||||||
return {
|
return {
|
||||||
method: request.method,
|
method: request.method,
|
||||||
url: request.url,
|
url: createUrl(request),
|
||||||
httpVersion: 'HTTP/1.1',
|
httpVersion: 'HTTP/1.1',
|
||||||
cookies: [],
|
cookies: [],
|
||||||
headers: createHeaders(request.headers, request.body.mode),
|
headers: createHeaders(request.headers, request.body.mode),
|
||||||
|
|||||||
Reference in New Issue
Block a user