Commit 28160389 authored by Abiola Ibrahim's avatar Abiola Ibrahim

Minor refactor.

parent fbad4e15
......@@ -28,17 +28,13 @@ func To(fs http.FileSystem, r *http.Request, to string, replacer httpserver.Repl
query = tparts[1]
}
if strings.HasSuffix(tparts[0], "/") && !strings.HasSuffix(t, "/") {
t += "/"
}
// add trailing slash for directories, if present
if strings.HasSuffix(v, "/") && !strings.HasSuffix(t, "/") {
if strings.HasSuffix(tparts[0], "/") && !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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment