Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fastify/fastify-static
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.0.1
Choose a base ref
...
head repository: fastify/fastify-static
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.0.2
Choose a head ref
  • 4 commits
  • 6 files changed
  • 5 contributors

Commits on Feb 8, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    84881c1 View commit details

Commits on Mar 4, 2024

  1. build(deps-dev): bump @typescript-eslint/parser from 6.21.0 to 7.1.0 (#…

    …442)
    
    * build(deps-dev): bump @typescript-eslint/parser from 6.21.0 to 7.1.0
    
    Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.21.0 to 7.1.0.
    - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
    - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
    - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v7.1.0/packages/parser)
    
    ---
    updated-dependencies:
    - dependency-name: "@typescript-eslint/parser"
      dependency-type: direct:development
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * also upgrade peer dep
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Aras Abbasi <aras.abbasi@googlemail.com>
    dependabot[bot] and Uzlopak authored Mar 4, 2024

    Partially verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    4e39bd8 View commit details

Commits on Mar 29, 2024

  1. Retain path when using fallback precompressed path (#445)

    colatkinson authored Mar 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7481334 View commit details
  2. v7.0.2

    Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
    gurgunday authored Mar 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    75bbed5 View commit details
Showing with 45 additions and 4 deletions.
  1. +3 −0 .gitignore
  2. +2 −1 index.js
  3. +3 −3 package.json
  4. +5 −0 test/static-pre-compressed/dir-gz/index.html
  5. BIN test/static-pre-compressed/dir-gz/index.html.gz
  6. +32 −0 test/static.test.js
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -147,3 +147,6 @@ yarn.lock
# editor files
.vscode
.idea

#tap files
.tap/
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -174,6 +174,7 @@ async function fastifyStatic (fastify, opts) {
pumpOptions,
checkedEncodings
) {
const pathnameOrig = pathname
const options = Object.assign({}, sendOptions, pumpOptions)

if (rootPath) {
@@ -346,7 +347,7 @@ async function fastifyStatic (fastify, opts) {
return pumpSendToReply(
request,
reply,
pathname,
pathnameOrig,
rootPath,
rootPathOffset,
undefined,
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fastify/static",
"version": "7.0.1",
"version": "7.0.2",
"description": "Plugin for serving static files as fast as possible.",
"main": "index.js",
"type": "commonjs",
@@ -42,8 +42,8 @@
"@fastify/compress": "^7.0.0",
"@fastify/pre-commit": "^2.0.2",
"@types/node": "^20.1.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"concat-stream": "^2.0.0",
"coveralls": "^3.0.4",
"eslint-plugin-typescript": "^0.14.0",
5 changes: 5 additions & 0 deletions test/static-pre-compressed/dir-gz/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
dir-gz index
</body>
</html>
Binary file added test/static-pre-compressed/dir-gz/index.html.gz
Binary file not shown.
32 changes: 32 additions & 0 deletions test/static.test.js
Original file line number Diff line number Diff line change
@@ -46,6 +46,9 @@ const indexBr = fs.readFileSync(
const dirIndexBr = fs.readFileSync(
'./test/static-pre-compressed/dir/index.html.br'
)
const dirIndexGz = fs.readFileSync(
'./test/static-pre-compressed/dir-gz/index.html.gz'
)
const uncompressedStatic = fs
.readFileSync('./test/static-pre-compressed/uncompressed.html')
.toString('utf8')
@@ -3496,6 +3499,35 @@ t.test(
}
)

t.test(
'will serve precompressed gzip index in subdir',
async (t) => {
const pluginOptions = {
root: path.join(__dirname, '/static-pre-compressed'),
preCompressed: true
}

const fastify = Fastify()

fastify.register(fastifyStatic, pluginOptions)
t.teardown(fastify.close.bind(fastify))

const response = await fastify.inject({
method: 'GET',
url: '/dir-gz',
headers: {
'accept-encoding': 'gzip, deflate, br'
}
})

genericResponseChecks(t, response)
t.equal(response.headers['content-encoding'], 'gzip')
t.equal(response.statusCode, 200)
t.same(response.rawPayload, dirIndexGz)
t.end()
}
)

t.test(
'will serve precompressed index with alternative index option',
async (t) => {