Skip to content

Commit ab94985

Browse files
Zstorm999mrin9
authored andcommitted
fix: do not parse header content-type if empty
This commit defers the parsing of the `content-type` header until after we make sure this header is present.
1 parent 0825d00 commit ab94985

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/components/api-request.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,11 +1528,12 @@ export default class ApiRequest extends LitElement {
15281528
respHeadersObj[hdr] = hdrVal;
15291529
this.responseHeaders = `${this.responseHeaders}${hdr}: ${hdrVal}\n`;
15301530
});
1531-
const contentType = fetchResponse.headers.get('content-type').split(';')[0].trim();
1531+
let contentType = fetchResponse.headers.get('content-type');
15321532
const respEmpty = (await fetchResponse.clone().text()).length === 0;
15331533
if (respEmpty) {
15341534
this.responseText = '';
15351535
} else if (contentType) {
1536+
contentType = contentType.split(';')[0].trim();
15361537
if (contentType === 'application/x-ndjson') {
15371538
this.responseText = await fetchResponse.text();
15381539
} else if (contentType.includes('json')) {

0 commit comments

Comments
 (0)