summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolderpunk <solderpunk@sdf.org>2019-04-06 21:01:42 +0300
committerSolderpunk <solderpunk@sdf.org>2019-04-06 21:01:42 +0300
commit46621b961703fd14cf207a4f2e917110bea900d8 (patch)
tree0a4f5d91ec4a58707f911059944317bf20ebfd2d
parent6f93dc967da9928f2a6348641d2e843e111342f7 (diff)
Fix username path munging.
-rw-r--r--httphandlers.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/httphandlers.go b/httphandlers.go
index 8799cf8..76be7fa 100644
--- a/httphandlers.go
+++ b/httphandlers.go
@@ -36,18 +36,17 @@ func GetHandler(config Config) http.HandlerFunc {
return
}
// Resolve URI path to actual filesystem path
- // fmt.Println(r.URL.Path)
- bits := filepath.SplitList(r.URL.Path)
- // fmt.Println(bits[0])
path := r.URL.Path
- if strings.HasPrefix(bits[0], "/~") {
- bits[0] = strings.Replace(bits[0], "/~", "/home/", 1)
- bits[0] += config.HomeDocBase
- path = filepath.Join(bits...)
+ if strings.HasPrefix(path, "/~") {
+ bits := strings.Split(r.URL.Path, "/")
+ username := bits[1][1:]
+ //strings.Replace(bits[1], "~", "", 1)
+ new_prefix := filepath.Join("home", username, config.HomeDocBase)
+ path = strings.Replace(path, bits[1], new_prefix, 1)
} else {
path = filepath.Join(config.DocBase, r.URL.Path)
}
- // fmt.Println(path)
+ //fmt.Println(path)
// Fail if file does not exist
info, err := os.Stat(path)
if os.IsNotExist(err) {