| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c788829 commit dd03316
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,17 +98,17 @@ export function createStaticClient(): VitestClient { | |||
| 98 | 98 | ||
| 99 | 99 | async function registerMetadata() { | |
| 100 | 100 | 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)) | ||
| 108 | 108 | metadata = parse(decompressed) as HTMLReportMetadata | |
| 109 | 109 | } | |
| 110 | 110 | else { | |
| 111 | - metadata = parse(await res.text()) as HTMLReportMetadata | ||
| 111 | + metadata = parse(strFromU8(content)) as HTMLReportMetadata | ||
| 112 | 112 | } | |
| 113 | 113 | const event = new Event('open') | |
| 114 | 114 | ctx.ws.dispatchEvent(event) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments