Skip to content

Commit

Permalink
Fix tests failing on Go 1.20 on Windows. Clean works differently on 1…
Browse files Browse the repository at this point in the history
….20. Use path.Clean instead.
  • Loading branch information
aldas committed Feb 19, 2023
1 parent 4156b3c commit cc7cf11
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions middleware/csrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ func CSRFWithConfig(config CSRFConfig) echo.MiddlewareFunc {
config.CookieSecure = true
}

extractors, err := CreateExtractors(config.TokenLookup)
if err != nil {
panic(err)
extractors, cErr := CreateExtractors(config.TokenLookup)
if cErr != nil {
panic(cErr)
}

return func(next echo.HandlerFunc) echo.HandlerFunc {
Expand Down
6 changes: 3 additions & 3 deletions middleware/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ func JWTWithConfig(config JWTConfig) echo.MiddlewareFunc {
config.ParseTokenFunc = config.defaultParseToken
}

extractors, err := createExtractors(config.TokenLookup, config.AuthScheme)
if err != nil {
panic(err)
extractors, cErr := createExtractors(config.TokenLookup, config.AuthScheme)
if cErr != nil {
panic(cErr)
}
if len(config.TokenLookupFuncs) > 0 {
extractors = append(config.TokenLookupFuncs, extractors...)
Expand Down
6 changes: 3 additions & 3 deletions middleware/key_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ func KeyAuthWithConfig(config KeyAuthConfig) echo.MiddlewareFunc {
panic("echo: key-auth middleware requires a validator function")
}

extractors, err := createExtractors(config.KeyLookup, config.AuthScheme)
if err != nil {
panic(err)
extractors, cErr := createExtractors(config.KeyLookup, config.AuthScheme)
if cErr != nil {
panic(cErr)
}

return func(next echo.HandlerFunc) echo.HandlerFunc {
Expand Down
8 changes: 4 additions & 4 deletions middleware/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc {
}

// Index template
t, err := template.New("index").Parse(html)
if err != nil {
panic(fmt.Sprintf("echo: %v", err))
t, tErr := template.New("index").Parse(html)
if tErr != nil {
panic(fmt.Errorf("echo: %w", tErr))
}

return func(next echo.HandlerFunc) echo.HandlerFunc {
Expand All @@ -176,7 +176,7 @@ func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc {
if err != nil {
return
}
name := filepath.Join(config.Root, filepath.Clean("/"+p)) // "/"+ for security
name := filepath.Join(config.Root, path.Clean("/"+p)) // "/"+ for security

if config.IgnoreBase {
routePath := path.Base(strings.TrimRight(c.Path(), "/*"))
Expand Down

0 comments on commit cc7cf11

Please sign in to comment.