mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-12 12:06:16 -08:00
fix(electron-backend): avoid double-gunzipping EPG responses
Stop treating content-encoding as a manual gunzip signal, because fetch already returns decoded bodies for transfer-compressed XMLTV responses. Keep redirect and payload-based gzip detection in place, and add regression coverage for redirected .gz feeds, gzip MIME types, content-disposition filenames, and plain content-encoding responses. Entire-Checkpoint: c6e522b4276c
This commit is contained in:
1 parent
5e6f58a758
commit
82c3004b3b
2 files changed
+21
-6
No files matched your search
@@ -19,12 +19,32 @@ describe('shouldGunzipEpgResponse', () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true for gzip content-encoding even without a .gz path', () => {
|
||||
it('returns false for gzip content-encoding without a gzip payload', () => {
|
||||
expect(
|
||||
shouldGunzipEpgResponse('https://example.com/guide', {
|
||||
headers: new Headers([['content-encoding', 'gzip']]),
|
||||
url: 'https://example.com/guide',
|
||||
})
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true for gzip mime types', () => {
|
||||
expect(
|
||||
shouldGunzipEpgResponse('https://example.com/guide', {
|
||||
headers: new Headers([['content-type', 'application/gzip']]),
|
||||
url: 'https://example.com/guide',
|
||||
})
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true when content-disposition advertises a .gz filename', () => {
|
||||
expect(
|
||||
shouldGunzipEpgResponse('https://example.com/guide', {
|
||||
headers: new Headers([
|
||||
['content-disposition', 'attachment; filename="guide.xml.gz"'],
|
||||
]),
|
||||
url: 'https://example.com/guide',
|
||||
})
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -22,11 +22,6 @@ export function shouldGunzipEpgResponse(
|
||||
return true;
|
||||
}
|
||||
|
||||
const contentEncoding = response.headers.get('content-encoding');
|
||||
if (contentEncoding?.toLowerCase().includes('gzip')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const contentType = response.headers.get('content-type');
|
||||
if (
|
||||
contentType &&
|
||||
|
||||
Reference in new issue
Block a user