summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbiola Ibrahim <abiola89@gmail.com>2016-06-22 05:49:46 +0100
committerGitHub <noreply@github.com>2016-06-22 05:49:46 +0100
commitfd8fe24bcbe76242adbbc3dcbfa57b3985fed925 (patch)
tree3f110ad892375046aa4fb627c12c061fe47b5c53
parentfbad4e15c2c0b2dd0aa105891b4e55ab29171f67 (diff)
parent281603895bc7d501b6897abc3e7bee16e95bf7a6 (diff)
Merge pull request #899 from abiosoft/master
Minor refactor for rewrite.
-rw-r--r--caddyhttp/rewrite/to.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/caddyhttp/rewrite/to.go b/caddyhttp/rewrite/to.go
index 75f69400..5371920d 100644
--- a/caddyhttp/rewrite/to.go
+++ b/caddyhttp/rewrite/to.go
@@ -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
}