vapor/vapor

File Middleware strips query parameters with redirect

Captain-Kirkie opened this issue · 2 comments

Describe the bug

When using the the DirectoryAction .redirect on FileMiddleWare we lose any query parameters sent with the request on redirect.

Example:
GET /Utilities?test=test -> 301 Moved Permanently /Utilities/ (Query parameters are stripped.)

To Reproduce

To reproduce:

  1. Use Vapor FileMiddleware with directory action .redirect.
  2. Serve files through file middleware.
  3. Make getRequest without trailing "/" and add query parameters GET /Utilities?test=test.

Steps to reproduce the behavior:

  1. Add package with configuration '...'
  2. Send request with options '...'
  3. See error

Expected behavior

GET /Utilities?test=test -> 301 Moved Permanently /Utilities/?test=test (Query parameters persist)

Environment

  • Vapor Framework version: framework: 4.78.2
  • Vapor Toolbox version: toolbox: 18.7.1
  • OS version: MacOS Ventura Version 13.6

Additional context

Add any other context about the problem here.

Pull request Here

Fixed in #3077