Skip to content

Commit

Permalink
refactor: improve the Content-Type matching
Browse files Browse the repository at this point in the history
  • Loading branch information
YumoImer committed Dec 3, 2024
1 parent 7e467fc commit 5827f70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/x-request/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('XRequest Class', () => {
ok: true,
status: 200,
headers: {
get: jest.fn().mockReturnValue('application/json'),
get: jest.fn().mockReturnValue('application/json; charset=utf-8'),
},
json: jest.fn().mockResolvedValueOnce(params),
});
Expand Down
4 changes: 3 additions & 1 deletion components/x-request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ class XRequestClass {

const contentType = response.headers.get('content-type') || '';

switch (contentType) {
const mimeType = contentType.split(';')[0].trim();

switch (mimeType) {
/** SSE */
case 'text/event-stream':
await this.sseResponseHandler<Output>(response, callbacks);
Expand Down

0 comments on commit 5827f70

Please sign in to comment.