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

Make FS return a redirect for directories without trailing slash #802

Merged
merged 4 commits into from May 18, 2020

Conversation

moqmar
Copy link
Contributor

@moqmar moqmar commented May 5, 2020

Fixes #792

@erikdubbelboer
Copy link
Collaborator

Thanks. Can you add a test case please?

@moqmar
Copy link
Contributor Author

moqmar commented May 15, 2020

I've added a test case and actually found an issue due to that :D

I'm not completely sure though if there are other functions making use of fs though that way (overriding the request URI before letting it serve a file or directory) - I haven't found any yet at least.

fs_test.go Outdated Show resolved Hide resolved
@erikdubbelboer erikdubbelboer merged commit 5bd1b0c into valyala:master May 18, 2020
@kimkit
Copy link

kimkit commented Aug 19, 2020

@moqmar is it better to use origin path for redirect ?

https://github.com/valyala/fasthttp/blob/master/fs.go#L738

ctx.RedirectBytes(append(ctx.Path(), '/'), StatusFound)

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

Successfully merging this pull request may close these issues.

FS: redirect directories to have a trailing slash
3 participants