Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-02-11 21:50:05 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-02-11 21:50:05 +0300
commit609bdfcaeceac3588de625955367476192c411b7 (patch)
treef32f34cf970043983cf6e615381770b229d288ea
parentfbf2a3f06dea7ac2468c6d027518fc62b642bef0 (diff)
Make the verify pass
-rw-r--r--domain.go25
1 files changed, 11 insertions, 14 deletions
diff --git a/domain.go b/domain.go
index 0b0f2c6d..32a8b09c 100644
--- a/domain.go
+++ b/domain.go
@@ -63,27 +63,24 @@ func (d *domain) checkPath(w http.ResponseWriter, r *http.Request, path string)
return
}
- // If this file is directory, open the index.html
- if fi.IsDir() {
- // If the URL doesn't end with /, send location to client
- if !strings.HasSuffix(r.URL.Path, "/") {
- newURL := *r.URL
- newURL.Path += "/"
- http.Redirect(w, r, newURL.String(), 302)
- return
- }
-
+ switch {
+ // If the URL doesn't end with /, send location to client
+ case fi.IsDir() && !strings.HasSuffix(r.URL.Path, "/"):
+ newURL := *r.URL
+ newURL.Path += "/"
+ http.Redirect(w, r, newURL.String(), 302)
+
+ // If this is directory, we try the index.html
+ case fi.IsDir():
fullPath = filepath.Join(fullPath, "index.html")
fi, err = os.Lstat(fullPath)
if err != nil {
return
}
- }
- // We don't allow to open non-regular files
- if !fi.Mode().IsRegular() {
+ // We don't allow to open the regular file
+ case !fi.Mode().IsRegular():
err = fmt.Errorf("%s: is not a regular file", fullPath)
- return
}
return
}