summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--finger.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/finger.go b/finger.go
index dd495f9..bb8a6d6 100644
--- a/finger.go
+++ b/finger.go
@@ -52,16 +52,17 @@ func fingerHandler(route RouteDirective) sr.Handler {
}
return sr.HandlerFunc(func(ctx context.Context, request *sr.Request) *sr.Response {
- u, err := user.Lookup(strings.TrimPrefix(request.Path, "/"))
- if err != nil {
- return nil
- }
+ username := strings.TrimPrefix(request.Path, "/")
var fpath string
if strings.HasPrefix(route.FsPath, "~/") {
+ u, err := user.Lookup(username)
+ if err != nil {
+ return nil
+ }
fpath = filepath.Join(u.HomeDir, route.FsPath[2:])
} else {
- fpath = strings.Replace(route.FsPath, "~", u.Username, 1)
+ fpath = strings.Replace(route.FsPath, "~", username, 1)
}
st, err := os.Stat(fpath)