diff options
-rw-r--r-- | domain.go | 2 | ||||
-rw-r--r-- | helpers.go | 5 |
2 files changed, 6 insertions, 1 deletions
@@ -112,7 +112,7 @@ func (d *domain) checkPath(w http.ResponseWriter, r *http.Request, path string) switch { // If the URL doesn't end with /, send location to client - case fi.IsDir() && !strings.HasSuffix(r.URL.Path, "/"): + case fi.IsDir() && !endsWithSlash(r.URL.Path): newURL := *r.URL newURL.Path += "/" http.Redirect(w, r, newURL.String(), 302) @@ -4,6 +4,7 @@ import ( "io/ioutil" "log" "net" + "strings" ) func readFile(file string) (result []byte) { @@ -28,3 +29,7 @@ func createSocket(addr string) (l net.Listener, fd uintptr) { fd = f.Fd() return } + +func endsWithSlash(path string) bool { + return strings.HasSuffix(path, "/") +} |