diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-09-23 13:18:30 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-09-23 13:18:30 -0600 |
commit | efd97622985f1131889d4561f8a3ba0b061e896e (patch) | |
tree | 41f7cbc71aa4cd6a89c50bc7aa3248b0cc294722 /contrib/sharedhost/replacement.go | |
parent | 210e4d038e4be64490be02d6777254cf42e12503 (diff) |
improve shared host path handling
Diffstat (limited to 'contrib/sharedhost/replacement.go')
-rw-r--r-- | contrib/sharedhost/replacement.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/contrib/sharedhost/replacement.go b/contrib/sharedhost/replacement.go index 9dc3a1e..cabc6b1 100644 --- a/contrib/sharedhost/replacement.go +++ b/contrib/sharedhost/replacement.go @@ -4,6 +4,7 @@ import ( "context" "crypto/tls" "net/url" + "path" sr "tildegit.org/tjp/sliderule" ) @@ -20,9 +21,9 @@ import ( func ReplaceTilde(replacement string) sr.Middleware { return func(inner sr.Handler) sr.Handler { return sr.HandlerFunc(func(ctx context.Context, request *sr.Request) *sr.Response { - if len(request.Path) > 1 && request.Path[0] == '/' && request.Path[1] == '~' { + if len(request.Path) > 1 && request.Path[0:2] == "/~" { request = cloneRequest(request) - request.Path = "/" + replacement + request.Path[2:] + request.Path = path.Clean("/" + replacement + request.Path[2:]) } return inner.Handle(ctx, request) |