-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace into-stream with Readable.from
Signed-off-by: Matteo Collina <hello@matteocollina.com>
- Loading branch information
Showing
4 changed files
with
3,861 additions
and
6 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const Fastify = require('fastify') | ||
const fastifyCompress = require('..') | ||
const fsPromises = require("fs").promises | ||
const { join } = require('path') | ||
const { fetch } = require('undici') | ||
|
||
test('should not corrupt the file content', async (t) => { | ||
const fastify = new Fastify() | ||
t.teardown(() => fastify.close()) | ||
|
||
fastify.register(async (instance, opts) => { | ||
await fastify.register(fastifyCompress) | ||
instance.get('/issue', async (req, reply) => { | ||
const longStringWithEmoji = await fsPromises.readFile(join(__dirname, "./test.txt"), "utf-8"); | ||
|
||
return longStringWithEmoji // <--- the file content is corrupt | ||
// search for "hydra.alibaba.com" will see 2 wired question marks instead of emoji | ||
}) | ||
Check failure Code scanning / CodeQL Missing rate limiting High test
This route handler performs
a file system access Error loading related location Loading |
||
}) | ||
|
||
fastify.get('/good', async (req, reply) => { | ||
const longStringWithEmoji = await fsPromises.readFile(join(__dirname, "./test.txt"), "utf-8"); | ||
|
||
return longStringWithEmoji // <--- the file content is ok | ||
// search for "hydra.alibaba.com" will see emoji | ||
}) | ||
Check failure Code scanning / CodeQL Missing rate limiting High test
This route handler performs
a file system access Error loading related location Loading |
||
|
||
await fastify.listen({ port: 0 }) | ||
|
||
const { port } = fastify.server.address() | ||
const url = `http://localhost:${port}` | ||
const response = await fetch(`${url}/issue`) | ||
const response2 = await fetch(`${url}/good`) | ||
const body = await response.text() | ||
const body2 = await response2.text() | ||
t.equal(body, body2) | ||
}) |
Oops, something went wrong.