Skip to content

Commit 3c59207

Browse files
authored
feat: support xz-compressed coverage (#10)
1 parent 851f3e8 commit 3c59207

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

coverage/index.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
tr.open-file + tr.details td { border-left:4px solid #a3d8ff; }
3535
@media (max-width:600px) { table { display:block; overflow-x:auto; white-space:nowrap; } th { top:0; } }
3636
</style>
37+
<script>
38+
window["stream/web"] = { ReadableStream, TransformStream, WritableStream };
39+
</script>
40+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/package/xz-decompress.js"></script>
3741
</head>
3842
<body>
3943
<header>
@@ -137,9 +141,14 @@
137141
}
138142

139143
async function fetchText(url){
140-
if (url.pathname.endsWith('.xz')) throw new Error('.xz compression not supported');
141144
const res = await fetch(url);
142145
if (!res.ok) throw new Error('HTTP ' + res.status);
146+
if (url.pathname.endsWith('.xz')){
147+
const xz = window['xz-decompress'];
148+
if (!xz?.XzReadableStream) throw new Error('xz not supported in this browser');
149+
const stream = new xz.XzReadableStream(res.body);
150+
return await new Response(stream).text();
151+
}
143152
if (url.pathname.endsWith('.gz')){
144153
if (!('DecompressionStream' in window)) throw new Error('gzip not supported in this browser');
145154
const ds = new DecompressionStream('gzip');
@@ -391,7 +400,7 @@
391400
const pathVal=pathInput.value.trim();
392401
if(!pathVal){ status('Path required'); filesData=[]; renderSummary(); renderTable(); return; }
393402
if(!params.get('srcRoot')){
394-
const m=pathVal.match(/[\\/]([0-9a-f]{40})[\\/]lcov\.info$/);
403+
const m=pathVal.match(/[\\/]([0-9a-f]{40})[\\/]lcov\.info(?:\.gz|\.xz)?$/);
395404
srcRoot = m ? `https://raw.githubusercontent.com/gluesql/gluesql/${m[1]}/` : '';
396405
}
397406
status('Loading...');

0 commit comments

Comments
 (0)