0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

Minor refactor.

This commit is contained in:
Abiola Ibrahim 2016-06-22 05:36:29 +01:00
parent fbad4e15c2
commit 281603895b

View file

@ -28,17 +28,13 @@ func To(fs http.FileSystem, r *http.Request, to string, replacer httpserver.Repl
query = tparts[1]
}
// add trailing slash for directories, if present
if strings.HasSuffix(tparts[0], "/") && !strings.HasSuffix(t, "/") {
t += "/"
}
// add trailing slash for directories, if present
if strings.HasSuffix(v, "/") && !strings.HasSuffix(t, "/") {
t += "/"
}
// validate file
if isValidFile(fs, t) {
if validFile(fs, t) {
break
}
}
@ -70,9 +66,9 @@ func To(fs http.FileSystem, r *http.Request, to string, replacer httpserver.Repl
return RewriteDone
}
// isValidFile checks if file exists on the filesystem.
// validFile checks if file exists on the filesystem.
// if file ends with `/`, it is validated as a directory.
func isValidFile(fs http.FileSystem, file string) bool {
func validFile(fs http.FileSystem, file string) bool {
if fs == nil {
return false
}