Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,7 @@ describe('StartWorkWebviewController', () => {

await controller.onMessageReceived(externalImageAction);

// Note: The implementation has a bug - it should return after posting the empty response,
// but it continues and tries to fetch the external URL
expect(mockTransportFactory.get).toHaveBeenCalledWith('https://external.com/image.png', {
method: 'GET',
headers: {
Authorization: undefined,
},
responseType: 'arraybuffer',
});
expect(mockTransportFactory.get).not.toHaveBeenCalled();
expect(mockMessagePoster).toHaveBeenCalledWith({
type: 'getImageDone',
imgData: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export class StartWorkWebviewController implements WebviewController<StartWorkIs
imgData: '',
nonce: msg.nonce,
} as any);
break;
}

const url = href.toString();
Expand Down
22 changes: 22 additions & 0 deletions src/webviews/jiraIssueWebview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,28 @@ describe('JiraIssueWebview', () => {
});
});

test('should skip external images and not fetch', async () => {
const mockGet = jest.fn().mockResolvedValue({ data: Buffer.from('image-data') });
mockJiraClient.transportFactory.mockReturnValue({ get: mockGet });

const msg = {
action: 'getImage',
url: 'https://external.com/image.png',
nonce: 'nonce-123',
};

const postMessageSpy = jest.spyOn(jiraIssueWebview as any, 'postMessage');

await jiraIssueWebview['onMessageReceived'](msg);

expect(mockGet).not.toHaveBeenCalled();
expect(postMessageSpy).toHaveBeenCalledWith({
type: 'getImageDone',
imgData: '',
nonce: 'nonce-123',
});
});

test('should handle refreshIssue action', async () => {
const msg = { action: 'refreshIssue' };

Expand Down
1 change: 1 addition & 0 deletions src/webviews/jiraIssueWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,7 @@ export class JiraIssueWebview
imgData: '',
nonce: msg.nonce,
});
break;
}

const url = href.toString();
Expand Down
Loading