From b0d6f1aa49a4ff554c80ae49ab122aaab256001e Mon Sep 17 00:00:00 2001 From: Viktor Persson Date: Sat, 28 May 2022 21:35:49 +0200 Subject: [PATCH] Refactor favicon middleware, avoid magic numbers. (#1919) * Refactor favicon middleware, avoid magic numbers. * Introduce constant for path to favicon. --- middleware/favicon/favicon.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/middleware/favicon/favicon.go b/middleware/favicon/favicon.go index c2d12b32a3..5f7bcbfbb0 100644 --- a/middleware/favicon/favicon.go +++ b/middleware/favicon/favicon.go @@ -40,6 +40,7 @@ var ConfigDefault = Config{ } const ( + fPath = "/favicon.ico" hType = "image/x-icon" hAllow = "GET, HEAD, OPTIONS" hZero = "0" @@ -97,7 +98,7 @@ func New(config ...Config) fiber.Handler { } // Only respond to favicon requests - if len(c.Path()) != 12 || c.Path() != "/favicon.ico" { + if c.Path() != fPath { return c.Next() }