mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-24 17:03:47 +01:00
fix/collection-search-validations unit-tests-fix (#2833)
* fix: updates * fix: update test title * fix: removed console
This commit is contained in:
parent
22c096507d
commit
eceb114d6c
@ -3,7 +3,7 @@ import filter from 'lodash/filter';
|
||||
import find from 'lodash/find';
|
||||
|
||||
export const doesRequestMatchSearchText = (request, searchText = '') => {
|
||||
return request.name.toLowerCase().includes(searchText.toLowerCase());
|
||||
return request?.name?.toLowerCase().includes(searchText.toLowerCase());
|
||||
};
|
||||
|
||||
export const doesFolderHaveItemsMatchSearchText = (item, searchText = '') => {
|
||||
|
@ -123,7 +123,8 @@ const curlToJson = (curlCommand) => {
|
||||
request.urlWithoutQuery = 'http://' + request.urlWithoutQuery;
|
||||
}
|
||||
|
||||
requestJson.url = request.urlWithoutQuery
|
||||
requestJson.url = request.urlWithoutQuery;
|
||||
requestJson.raw_url = request.url;
|
||||
requestJson.method = request.method;
|
||||
|
||||
if (request.cookies) {
|
||||
|
@ -75,4 +75,15 @@ describe('curlToJson', () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should return and parse a simple curl command with a trailing slash', () => {
|
||||
const curlCommand = 'curl https://www.usebruno.com/';
|
||||
const result = curlToJson(curlCommand);
|
||||
|
||||
expect(result).toEqual({
|
||||
url: 'https://www.usebruno.com/',
|
||||
raw_url: 'https://www.usebruno.com/',
|
||||
method: 'get'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -187,10 +187,21 @@ const parseCurlCommand = (curlCommand) => {
|
||||
}
|
||||
|
||||
urlObject.search = null; // Clean out the search/query portion.
|
||||
|
||||
let urlWithoutQuery = URL.format(urlObject);
|
||||
let urlHost = urlObject?.host;
|
||||
if (!url?.includes(`${urlHost}/`)) {
|
||||
if (urlWithoutQuery && urlHost) {
|
||||
const [beforeHost, afterHost] = urlWithoutQuery.split(urlHost);
|
||||
urlWithoutQuery = beforeHost + urlHost + afterHost?.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
const request = {
|
||||
url: url,
|
||||
urlWithoutQuery: URL.format(urlObject)
|
||||
url,
|
||||
urlWithoutQuery
|
||||
};
|
||||
|
||||
if (compressed) {
|
||||
request.compressed = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user