Skip to content

Commit

Permalink
Simplify cleanPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Andres Virviescas Santana committed Jun 21, 2021
1 parent 53538e1 commit d7e5bc6
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions path.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package router

import (
"github.com/savsgio/gotils/strings"
"strings"

gstrings "github.com/savsgio/gotils/strings"
)

// cleanPath removes the '.' if it is the last character of the route
func cleanPath(path string) string {
lenPath := len(path)

if path[lenPath-1] == '.' {
path = path[:lenPath-1]
}

return path
return strings.TrimSuffix(path, ".")
}

// getOptionalPaths returns all possible paths when the original path
Expand Down Expand Up @@ -77,7 +73,7 @@ walk:
// include the root slash because the param is in the first segment
paths = append(paths, "/")

} else if !strings.Include(paths, path[:start-2]) {
} else if !gstrings.Include(paths, path[:start-2]) {
// include the path without the wildcard
// -2 due to remove the '/' and '{'
paths = append(paths, path[:start-2])
Expand Down

0 comments on commit d7e5bc6

Please sign in to comment.