add slash

This commit is contained in:
xgdgsc 2022-08-22 12:59:12 +08:00 committed by GitHub
parent bfed9b4320
commit 7706bf250f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,7 +111,12 @@ func (server *Server) Run(ctx context.Context, options ...RunOption) error {
if server.options.EnableRandomUrl { if server.options.EnableRandomUrl {
path = "/" + randomstring.Generate(server.options.RandomUrlLength) + "/" path = "/" + randomstring.Generate(server.options.RandomUrlLength) + "/"
} }
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
if !strings.HasSuffix(path, "/") {
path = path + "/"
}
handlers := server.setupHandlers(cctx, cancel, path, counter) handlers := server.setupHandlers(cctx, cancel, path, counter)
srv, err := server.setupHTTPServer(handlers) srv, err := server.setupHTTPServer(handlers)
if err != nil { if err != nil {