1
0
Fork 0

len(path) moved down to where it is used.

This commit is contained in:
Alexander Andreev 2023-09-05 17:56:02 +04:00
parent 3e6d03db1a
commit 32e7468eef
Signed by: Arav
GPG Key ID: D22A817D95815393
1 changed files with 1 additions and 2 deletions

View File

@ -38,14 +38,13 @@ func newPath(path string) (path, error) {
// newServePath is a reduced version of newPath for ServeHTTP.
func newServePath(path string) (path, error) {
pathLen := len(path)
if path[0] != '/' {
return nil, errors.New("path should start with a slash symbol \"/\"")
}
path = strings.ReplaceAll(path, "//", "/")
pathLen := len(path)
if path[pathLen-1] == '/' {
path = path[:pathLen-1]
}