MCPcopy
hub / github.com/vitest-dev/vitest / registerMetadata

Function registerMetadata

packages/ui/client/composables/client/static.ts:91–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89 }
90
91 async function registerMetadata() {
92 const res = await fetch(window.METADATA_PATH!)
93 const content = new Uint8Array(await res.arrayBuffer())
94
95 // Check for gzip magic numbers (0x1f 0x8b) to determine if content is compressed.
96 // This handles cases where a static server incorrectly sets Content-Encoding: gzip
97 // for .gz files, causing the browser to auto-decompress before we process the raw gzip data.
98 if (content.length >= 2 && content[0] === 0x1F && content[1] === 0x8B) {
99 const decompressed = strFromU8(decompressSync(content))
100 metadata = parse(decompressed) as HTMLReportMetadata
101 }
102 else {
103 metadata = parse(strFromU8(content)) as HTMLReportMetadata
104 }
105 const event = new Event('open')
106 ctx.ws.dispatchEvent(event)
107 }
108
109 registerMetadata()
110

Callers 2

reconnectFunction · 0.85
createStaticClientFunction · 0.85

Calls 2

fetchFunction · 0.85
parseFunction · 0.50

Tested by

no test coverage detected