瀏覽代碼

add an edge case from httprouter (#1407)

田欧 7 年之前
父節點
當前提交
1f59bad84b
共有 2 個文件被更改,包括 2 次插入1 次删除
  1. 1 1
      path.go
  2. 1 0
      path_test.go

+ 1 - 1
path.go

@@ -41,7 +41,7 @@ func cleanPath(p string) string {
 		buf[0] = '/'
 	}
 
-	trailing := n > 2 && p[n-1] == '/'
+	trailing := n > 1 && p[n-1] == '/'
 
 	// A bit more clunky without a 'lazybuf' like the path package, but the loop
 	// gets completely inlined (bufApp). So in contrast to the path package this

+ 1 - 0
path_test.go

@@ -24,6 +24,7 @@ var cleanTests = []struct {
 
 	// missing root
 	{"", "/"},
+	{"a/", "/a/"},
 	{"abc", "/abc"},
 	{"abc/def", "/abc/def"},
 	{"a/b/c", "/a/b/c"},