-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow loading gzipped fixtures (#644)
When loading a file that ends in `.gz`, `sirv` will set the `Content-Encoding` header to `gzip` which means browsers will unzip the content before handing it back to `fetch` or `XMLHttpRequest`. This PR adds a workaround to the asset server that sets the header to a garbage value if a file ending in `.gz` has been requested. It's necessary to use a garbage value because `sirv` will only set the header if it's not been set already, so we can't simply delete it. Refs: lukeed/sirv#158 Refs: ipfs/aegir#1462
- Loading branch information
1 parent
fd652e1
commit 2764b63
Showing
4 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { equal } = require('uvu/assert') | ||
|
||
describe('fixtures', () => { | ||
it('should load a gzipped tar file', async () => { | ||
const resp = await fetch('mocks/fixtures/file.tar.gz') | ||
const buf = await resp.arrayBuffer() | ||
const ui8 = new Uint8Array(buf) | ||
const base64 = btoa(String.fromCodePoint(...ui8)) | ||
|
||
equal(base64, 'H4sICIlTHVIACw==') | ||
}) | ||
}) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters