Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Sync): Do not show conflicts for empty keys #7556

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/insomnia/src/common/__tests__/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ describe('export', () => {
const exportWorkspacesDataJson = JSON.parse(exportedWorkspacesJson);
const exportWorkspacesDataYaml = YAML.parse(exportedWorkspacesYaml);
// Ensure JSON is the same as YAML
expect(exportWorkspacesDataJson.resources).toEqual(exportWorkspacesDataYaml.resources);
expect(exportWorkspacesDataYaml.resources).toMatchObject(exportWorkspacesDataJson.resources);
expect(exportWorkspacesDataJson).toMatchObject({
_type: 'export',
__export_format: 4,
Expand Down
5 changes: 3 additions & 2 deletions packages/insomnia/src/common/export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,11 @@ export async function exportRequestsData(
return d;
});

const stringifiedData = JSON.stringify(data);
if (format.toLowerCase() === 'yaml') {
return YAML.stringify(data);
return YAML.stringify(JSON.parse(stringifiedData));
Comment on lines +271 to +273
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like it might be a regression

} else if (format.toLowerCase() === 'json') {
return JSON.stringify(data);
return stringifiedData;
} else {
throw new Error(`Invalid export format ${format}. Must be "json" or "yaml"`);
}
Expand Down
18 changes: 9 additions & 9 deletions packages/insomnia/src/models/__tests__/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ describe('init()', () => {
name: 'New Request',
description: '',
parameters: [],
pathParameters: [],
preRequestScript: '',
afterResponseScript: '',
pathParameters: undefined,
preRequestScript: undefined,
afterResponseScript: undefined,
url: '',
settingStoreCookies: true,
settingSendCookies: true,
Expand Down Expand Up @@ -59,9 +59,9 @@ describe('create()', () => {
method: 'GET',
name: 'Test Request',
parameters: [],
pathParameters: [],
preRequestScript: '',
afterResponseScript: '',
pathParameters: undefined,
preRequestScript: undefined,
afterResponseScript: undefined,
url: '',
settingStoreCookies: true,
settingSendCookies: true,
Expand Down Expand Up @@ -394,9 +394,9 @@ describe('migrate()', () => {
headers: [],
authentication: {},
parameters: [],
pathParameters: [],
preRequestScript: '',
afterResponseScript: '',
pathParameters: undefined,
preRequestScript: undefined,
afterResponseScript: undefined,
parentId: null,
body: {
mimeType: '',
Expand Down
12 changes: 6 additions & 6 deletions packages/insomnia/src/models/request-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ interface BaseRequestGroup {
environment: Record<string, any>;
environmentPropertyOrder: Record<string, any> | null;
metaSortKey: number;
preRequestScript: string;
afterResponseScript: string;
preRequestScript?: string;
afterResponseScript?: string;
authentication?: RequestAuthentication | {};
headers?: RequestHeader[];
}
Expand All @@ -36,10 +36,10 @@ export function init(): BaseRequestGroup {
environment: {},
environmentPropertyOrder: null,
metaSortKey: -1 * Date.now(),
preRequestScript: '',
afterResponseScript: '',
authentication: {},
headers: [],
preRequestScript: undefined,
afterResponseScript: undefined,
authentication: undefined,
headers: undefined,
};
}

Expand Down
12 changes: 6 additions & 6 deletions packages/insomnia/src/models/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ export interface BaseRequest {
description: string;
method: string;
body: RequestBody;
preRequestScript: string;
afterResponseScript: string;
preRequestScript?: string;
afterResponseScript?: string;
parameters: RequestParameter[];
pathParameters: RequestPathParameter[];
pathParameters?: RequestPathParameter[];
headers: RequestHeader[];
authentication: RequestAuthentication | {};
metaSortKey: number;
Expand Down Expand Up @@ -289,14 +289,14 @@ export function init(): BaseRequest {
description: '',
method: METHOD_GET,
body: {},
preRequestScript: '',
afterResponseScript: '',
parameters: [],
headers: [],
authentication: {},
preRequestScript: undefined,
metaSortKey: -1 * Date.now(),
isPrivate: false,
pathParameters: [],
pathParameters: undefined,
afterResponseScript: undefined,
// Settings
settingStoreCookies: true,
settingSendCookies: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/insomnia/src/models/websocket-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface BaseWebSocketRequest {
headers: RequestHeader[];
authentication: RequestAuthentication | {};
parameters: RequestParameter[];
pathParameters: RequestPathParameter[];
pathParameters?: RequestPathParameter[];
settingEncodeUrl: boolean;
settingStoreCookies: boolean;
settingSendCookies: boolean;
Expand All @@ -44,7 +44,7 @@ export const init = (): BaseWebSocketRequest => ({
headers: [],
authentication: {},
parameters: [],
pathParameters: [],
pathParameters: undefined,
settingEncodeUrl: true,
settingStoreCookies: true,
settingSendCookies: true,
Expand Down
6 changes: 3 additions & 3 deletions packages/insomnia/src/plugins/context/__tests__/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ describe('app.export.*', () => {
modified: 222,
name: 'New Request',
parameters: [],
pathParameters: [],
preRequestScript: '',
afterResponseScript: '',
pathParameters: undefined,
preRequestScript: undefined,
afterResponseScript: undefined,
parentId: 'wrk_1',
settingDisableRenderRequestBody: false,
settingEncodeUrl: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/ui/components/panes/request-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const RequestPane: FC<Props> = ({
if (!activeRequest) {
return <PlaceholderRequestPane />;
}
const pathParameters = getCombinedPathParametersFromUrl(activeRequest.url, activeRequest.pathParameters);
const pathParameters = getCombinedPathParametersFromUrl(activeRequest.url, activeRequest.pathParameters || []);

const onPathParameterChange = (pathParameters: RequestParameter[]) => {
patchRequest(requestId, { pathParameters });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export const WebSocketRequestPane: FC<Props> = ({ environment }) => {
};

// Path parameters are path segments that start with a colon (:)
const pathParameters = getCombinedPathParametersFromUrl(activeRequest.url, activeRequest.pathParameters);
const pathParameters = getCombinedPathParametersFromUrl(activeRequest.url, activeRequest.pathParameters || []);

const onPathParameterChange = (pathParameters: RequestPathParameter[]) => {
patchRequest(requestId, { pathParameters });
Expand Down
Loading