From 32e7468eef20f2de02e0d07218cb8669fd2c26c8 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Tue, 5 Sep 2023 17:56:02 +0400 Subject: [PATCH] len(path) moved down to where it is used. --- httpr.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpr.go b/httpr.go index ad79a10..700bb99 100644 --- a/httpr.go +++ b/httpr.go @@ -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] }