diff --git a/config.go b/config.go index 4a75b4d..d21cea6 100644 --- a/config.go +++ b/config.go @@ -214,6 +214,9 @@ func readconfig(configPath string) error { if serve.Path == "" { log.Fatal("a path must be specified in each serve entry") } + if len(serve.Path) > 1 && serve.Path[len(serve.Path)-1] == '/' { + serve.Path = serve.Path[:len(serve.Path)-1] + } if serve.Path[0] == '^' { serve.r = regexp.MustCompile(serve.Path) } diff --git a/go.mod b/go.mod index cf05d3d..f903a0e 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,6 @@ require ( github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/yookoala/gofast v0.4.1-0.20201013050739-975113c54107 gitlab.com/tslocum/gmitohtml v1.0.3-0.20201203184239-2a1abe8efe7c - golang.org/x/tools v0.0.0-20201203170353-bdde1628ed1d // indirect + golang.org/x/tools v0.0.0-20201204222352-654352759326 // indirect gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 ) diff --git a/go.sum b/go.sum index 58c49c8..95c43bb 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200908211811-12e1bf57a112/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201203170353-bdde1628ed1d h1:OuIGT9zWmMvqaajHPt4H4W1omjiKwkGpBw5ttuErmnw= -golang.org/x/tools v0.0.0-20201203170353-bdde1628ed1d/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201204222352-654352759326 h1:XKLw9EEEfGJFE2K5Ni4nXgtFBIfI+zKPIi2SlRYmIG4= +golang.org/x/tools v0.0.0-20201204222352-654352759326/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/server.go b/server.go index 2e654b7..c3e5cce 100644 --- a/server.go +++ b/server.go @@ -133,7 +133,7 @@ func servePath(c *tls.Conn, request *url.URL, serve *pathConfig) (int, int64) { if serve.Path[0] == '/' { pathSlashes++ // Regexp does not match starting slash } - if serve.Path[len(serve.Path)-1] != '/' { + if serve.Path[0] != '^' && serve.Path[len(serve.Path)-1] != '/' { pathSlashes++ } }