Skip to content
Merged
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
16 changes: 8 additions & 8 deletions packages/ui/client/composables/client/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ export function createStaticClient(): VitestClient {

async function registerMetadata() {
const res = await fetch(window.METADATA_PATH!)
const contentType = res.headers.get('content-type')?.toLowerCase() || ''
if (
contentType.includes('application/gzip')
|| contentType.includes('application/x-gzip')
) {
const compressed = new Uint8Array(await res.arrayBuffer())
const decompressed = strFromU8(decompressSync(compressed))
const content = new Uint8Array(await res.arrayBuffer())

// Check for gzip magic numbers (0x1f 0x8b) to determine if content is compressed.
// This handles cases where a static server incorrectly sets Content-Encoding: gzip
// for .gz files, causing the browser to auto-decompress before we process the raw gzip data.
if (content.length >= 2 && content[0] === 0x1F && content[1] === 0x8B) {
const decompressed = strFromU8(decompressSync(content))
metadata = parse(decompressed) as HTMLReportMetadata
}
else {
metadata = parse(await res.text()) as HTMLReportMetadata
metadata = parse(strFromU8(content)) as HTMLReportMetadata
}
const event = new Event('open')
ctx.ws.dispatchEvent(event)
Expand Down
Loading