Skip to content

Commit

Permalink
Refactor favicon middleware, avoid magic numbers. (gofiber#1919)
Browse files Browse the repository at this point in the history
* Refactor favicon middleware, avoid magic numbers.

* Introduce constant for path to favicon.
  • Loading branch information
vikpe authored and trim21 committed Aug 15, 2022
1 parent 8e29f00 commit b0d6f1a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion middleware/favicon/favicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var ConfigDefault = Config{
}

const (
fPath = "/favicon.ico"
hType = "image/x-icon"
hAllow = "GET, HEAD, OPTIONS"
hZero = "0"
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit b0d6f1a

Please sign in to comment.