Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain path when using fallback precompressed path #445

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

colatkinson
Copy link
Contributor

If there is no brotli-encoded asset and instead only a gzip-encoded one, the code first tries to serve the brotli-encoded form and then falls back on the gzip-encoded one. When doing so, however, it uses a path name that has been overwritten which leads to the wrong file being served.

For instance, if a request is for /dir/, then pathname will first be changed to index.html. On the retry, index.html will be used as the base pathname and thus /index.html will be served instead of /dir/index.html.


Unsure if there's a better way to fix. However, I'm hopeful that if there's a cleaner way, the test will at least demonstrate the bug more clearly.

Checklist

If there is no brotli-encoded asset and instead only a gzip-encoded one,
the code first tries to serve the brotli-encoded form and then falls
back on the gzip-encoded one. When doing so, however, it uses a path
name that has been overwritten which leads to the wrong file being
served.

For instance, if a request is for `/dir/`, then `pathname` will first be
changed to `index.html`. On the retry, `index.html` will be used as the
base pathname and thus `/index.html` will be served instead of
`/dir/index.html`.
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit 7481334 into fastify:master Mar 29, 2024
19 checks passed
@gurgunday
Copy link
Member

@colatkinson I will release a patch in a bit, this seems important

@colatkinson
Copy link
Contributor Author

@gurgunday Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants