Skip to content

Commit 353f02e

Browse files
committed
fix: Use nullish coalescing for Content-Type header
Replaced logical OR (||) with nullish coalescing operator (??) for fetching the 'Content-Type' header in `DefaultResponseProcess`. This change makes the assignment safer, as `??` only falls back to the default value (empty string) if `response.headers.get('Content-Type')` is strictly `null` or `undefined`, aligning with modern JavaScript best practices.
1 parent dbc2713 commit 353f02e

File tree

1 file changed

+1
-1
lines changed
  • console/atest-ui/src/views

1 file changed

+1
-1
lines changed

console/atest-ui/src/views/net.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function DefaultResponseProcess(response: any): Promise<any> {
4242
}
4343

4444
// Check if the content type is explicitly text/plain
45-
const contentType = response.headers.get('Content-Type') || '';
45+
const contentType = response.headers.get('Content-Type') ?? '';
4646
if (contentType.startsWith('text/plain')) {
4747
// For text/plain, directly return the text without parsing
4848
return await response.text();

0 commit comments

Comments
 (0)