From 6d798dbda94c72205881d3354337d18f7247de21 Mon Sep 17 00:00:00 2001 From: Xaver Fischer <33641215+Simerax@users.noreply.github.com> Date: Thu, 1 Dec 2022 08:53:40 +0100 Subject: [PATCH] :memo: middleware/filesystem does not handle url encoded values on it's own (#2247) * :memo: middleware/filesystem does not handle url encoded values * Update README.md add newline after first warning Co-authored-by: Xaver Fischer --- middleware/filesystem/README.md | 3 ++- middleware/filesystem/filesystem.go | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/middleware/filesystem/README.md b/middleware/filesystem/README.md index e976abf4a7..87caf1c841 100644 --- a/middleware/filesystem/README.md +++ b/middleware/filesystem/README.md @@ -2,7 +2,8 @@ Filesystem middleware for [Fiber](https://github.com/gofiber/fiber) that enables you to serve files from a directory. -⚠️ **`:params` & `:optionals?` within the prefix path are not supported!** +⚠️ **`:params` & `:optionals?` within the prefix path are not supported!** +⚠️ **To handle paths with spaces (or other url encoded values) make sure to set `fiber.Config{ UnescapePath: true}`** ## Table of Contents diff --git a/middleware/filesystem/filesystem.go b/middleware/filesystem/filesystem.go index aca5a1bf55..890fdf9824 100644 --- a/middleware/filesystem/filesystem.go +++ b/middleware/filesystem/filesystem.go @@ -64,7 +64,11 @@ var ConfigDefault = Config{ MaxAge: 0, } -// New creates a new middleware handler +// New creates a new middleware handler. +// +// filesystem does not handle url encoded values (for example spaces) +// on it's own. If you need that functionality, set "UnescapePath" +// in fiber.Config func New(config ...Config) fiber.Handler { // Set default config cfg := ConfigDefault