@fastify/static 7.0.1 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js
CHANGED
|
@@ -174,6 +174,7 @@ async function fastifyStatic (fastify, opts) {
|
|
|
174
174
|
pumpOptions,
|
|
175
175
|
checkedEncodings
|
|
176
176
|
) {
|
|
177
|
+
const pathnameOrig = pathname
|
|
177
178
|
const options = Object.assign({}, sendOptions, pumpOptions)
|
|
178
179
|
|
|
179
180
|
if (rootPath) {
|
|
@@ -346,7 +347,7 @@ async function fastifyStatic (fastify, opts) {
|
|
|
346
347
|
return pumpSendToReply(
|
|
347
348
|
request,
|
|
348
349
|
reply,
|
|
349
|
-
|
|
350
|
+
pathnameOrig,
|
|
350
351
|
rootPath,
|
|
351
352
|
rootPathOffset,
|
|
352
353
|
undefined,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastify/static",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"description": "Plugin for serving static files as fast as possible.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"@fastify/compress": "^7.0.0",
|
|
43
43
|
"@fastify/pre-commit": "^2.0.2",
|
|
44
44
|
"@types/node": "^20.1.0",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
46
|
-
"@typescript-eslint/parser": "^
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
46
|
+
"@typescript-eslint/parser": "^7.1.0",
|
|
47
47
|
"concat-stream": "^2.0.0",
|
|
48
48
|
"coveralls": "^3.0.4",
|
|
49
49
|
"eslint-plugin-typescript": "^0.14.0",
|
|
Binary file
|
package/test/static.test.js
CHANGED
|
@@ -46,6 +46,9 @@ const indexBr = fs.readFileSync(
|
|
|
46
46
|
const dirIndexBr = fs.readFileSync(
|
|
47
47
|
'./test/static-pre-compressed/dir/index.html.br'
|
|
48
48
|
)
|
|
49
|
+
const dirIndexGz = fs.readFileSync(
|
|
50
|
+
'./test/static-pre-compressed/dir-gz/index.html.gz'
|
|
51
|
+
)
|
|
49
52
|
const uncompressedStatic = fs
|
|
50
53
|
.readFileSync('./test/static-pre-compressed/uncompressed.html')
|
|
51
54
|
.toString('utf8')
|
|
@@ -3496,6 +3499,35 @@ t.test(
|
|
|
3496
3499
|
}
|
|
3497
3500
|
)
|
|
3498
3501
|
|
|
3502
|
+
t.test(
|
|
3503
|
+
'will serve precompressed gzip index in subdir',
|
|
3504
|
+
async (t) => {
|
|
3505
|
+
const pluginOptions = {
|
|
3506
|
+
root: path.join(__dirname, '/static-pre-compressed'),
|
|
3507
|
+
preCompressed: true
|
|
3508
|
+
}
|
|
3509
|
+
|
|
3510
|
+
const fastify = Fastify()
|
|
3511
|
+
|
|
3512
|
+
fastify.register(fastifyStatic, pluginOptions)
|
|
3513
|
+
t.teardown(fastify.close.bind(fastify))
|
|
3514
|
+
|
|
3515
|
+
const response = await fastify.inject({
|
|
3516
|
+
method: 'GET',
|
|
3517
|
+
url: '/dir-gz',
|
|
3518
|
+
headers: {
|
|
3519
|
+
'accept-encoding': 'gzip, deflate, br'
|
|
3520
|
+
}
|
|
3521
|
+
})
|
|
3522
|
+
|
|
3523
|
+
genericResponseChecks(t, response)
|
|
3524
|
+
t.equal(response.headers['content-encoding'], 'gzip')
|
|
3525
|
+
t.equal(response.statusCode, 200)
|
|
3526
|
+
t.same(response.rawPayload, dirIndexGz)
|
|
3527
|
+
t.end()
|
|
3528
|
+
}
|
|
3529
|
+
)
|
|
3530
|
+
|
|
3499
3531
|
t.test(
|
|
3500
3532
|
'will serve precompressed index with alternative index option',
|
|
3501
3533
|
async (t) => {
|