File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
packages/ui/client/composables/client Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -98,17 +98,17 @@ export function createStaticClient(): VitestClient {
9898
9999 async function registerMetadata ( ) {
100100 const res = await fetch ( window . METADATA_PATH ! )
101- const contentType = res . headers . get ( 'content-type' ) ?. toLowerCase ( ) || ''
102- if (
103- contentType . includes ( 'application/ gzip' )
104- || contentType . includes ( 'application/x- gzip' )
105- ) {
106- const compressed = new Uint8Array ( await res . arrayBuffer ( ) )
107- const decompressed = strFromU8 ( decompressSync ( compressed ) )
101+ const content = new Uint8Array ( await res . arrayBuffer ( ) )
102+
103+ // Check for gzip magic numbers (0x1f 0x8b) to determine if content is compressed.
104+ // This handles cases where a static server incorrectly sets Content-Encoding: gzip
105+ // for .gz files, causing the browser to auto-decompress before we process the raw gzip data.
106+ if ( content . length >= 2 && content [ 0 ] === 0x1F && content [ 1 ] === 0x8B ) {
107+ const decompressed = strFromU8 ( decompressSync ( content ) )
108108 metadata = parse ( decompressed ) as HTMLReportMetadata
109109 }
110110 else {
111- metadata = parse ( await res . text ( ) ) as HTMLReportMetadata
111+ metadata = parse ( strFromU8 ( content ) ) as HTMLReportMetadata
112112 }
113113 const event = new Event ( 'open' )
114114 ctx . ws . dispatchEvent ( event )
You can’t perform that action at this time.
0 commit comments