mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-27 15:10:49 +01:00
feat(#946): Prepend 'http://' to URL if no protocol is specified
This commit is contained in:
parent
0e320535a8
commit
2b08468581
packages/bruno-electron
@ -70,9 +70,16 @@ const setAuthHeaders = (axiosRequest, request, collectionRoot) => {
|
||||
return axiosRequest;
|
||||
};
|
||||
|
||||
const PROTOCOLS = ['http://', 'https://', 'wss://'];
|
||||
|
||||
const prepareRequest = (request, collectionRoot) => {
|
||||
const headers = {};
|
||||
let contentTypeDefined = false;
|
||||
let url = request.url;
|
||||
|
||||
if (PROTOCOLS.find((protocol) => url.startsWith(protocol)) === undefined) {
|
||||
url = `http://${url}`;
|
||||
}
|
||||
|
||||
// collection headers
|
||||
each(get(collectionRoot, 'request.headers', []), (h) => {
|
||||
@ -95,7 +102,7 @@ const prepareRequest = (request, collectionRoot) => {
|
||||
|
||||
let axiosRequest = {
|
||||
method: request.method,
|
||||
url: request.url,
|
||||
url: url,
|
||||
headers: headers,
|
||||
responseType: 'arraybuffer'
|
||||
};
|
||||
|
@ -0,0 +1,8 @@
|
||||
const prepareRequest = require('../../src/ipc/network/prepare-request');
|
||||
|
||||
describe('prepare-request: prepareRequest', () => {
|
||||
it("Should add 'http://' to the URL if no protocol is specified", () => {
|
||||
const request = prepareRequest({ method: 'GET', url: 'test', body: {} });
|
||||
expect(request.url).toEqual('http://test');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user