mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
Minor refactor.
This commit is contained in:
parent
fbad4e15c2
commit
281603895b
1 changed files with 4 additions and 8 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue