1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-23 11:56:00 +00:00
This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-01-09 05:41:20 +02:00
parent 72c2dafd2e
commit 8aedf6bc32
36 changed files with 99 additions and 130 deletions

View File

@@ -442,9 +442,9 @@ func StripPrefix(prefix string, h context.Handler) context.Handler {
func toWebPath(systemPath string) string {
// winos slash to slash
webpath := strings.Replace(systemPath, "\\", "/", -1)
webpath := strings.ReplaceAll(systemPath, "\\", "/")
// double slashes to single
webpath = strings.Replace(webpath, "//", "/", -1)
webpath = strings.ReplaceAll(webpath, "//", "/")
return webpath
}
@@ -1013,7 +1013,7 @@ func cacheFiles(ctx stdContext.Context, fs http.FileSystem, names []string, comp
case <-ctx.Done():
return ctx.Err()
default:
break
break // lint:ignore
}
if alg == "brotli" {
@@ -1218,7 +1218,7 @@ var _ http.File = (*dir)(nil)
// returns unorderded map of directories both reclusive and flat.
func findDirs(fs http.FileSystem, names []string) (map[string]*dir, error) {
dirs := make(map[string]*dir, 0)
dirs := make(map[string]*dir)
for _, name := range names {
f, err := fs.Open(name)

View File

@@ -19,7 +19,7 @@ func Param(name string) string {
// WildcardParam receives a parameter name prefixed with the WildcardParamStart symbol.
func WildcardParam(name string) string {
if len(name) == 0 {
if name == "" {
return ""
}
return prefix(name, WildcardParamStart)

View File

@@ -378,7 +378,7 @@ func formatPath(path string) string {
var formattedParts []string
parts := strings.Split(path, "/")
for _, part := range parts {
if len(part) == 0 {
if part == "" {
continue
}
if part[0] == startRune || part[0] == wildcardStartRune {
@@ -566,7 +566,7 @@ func (r *Route) Trace(w io.Writer, stoppedIndex int) {
if stoppedIndex != -1 && stoppedIndex <= len(r.Handlers) {
if i <= stoppedIndex {
pio.WriteRich(w, " ✓", pio.Green)
} else {
// } else {
// pio.WriteRich(w, " ✕", pio.Red, pio.Underline)
}
}

View File

@@ -136,10 +136,7 @@ func (router *Router) buildMainHandlerWithFilters(routerFilters map[Party]*Filte
}
if leftSlashLen == rightSlashLen {
if len(left.Path) > len(right.Path) {
return true
}
return false
return len(left.Path) > len(right.Path)
}
return len(left.Path) > len(right.Path)