small enhance for cleanPath (#1469)

from httprouter patch: https://github.com/julienschmidt/httprouter/pull/243
This commit is contained in:
田欧 2018-08-10 20:50:23 +08:00 committed by Bo-Yi Wu
parent 1f1bc429ed
commit 8fc8ce0472
1 changed files with 2 additions and 2 deletions

View File

@ -59,11 +59,11 @@ func cleanPath(p string) string {
case p[r] == '.' && p[r+1] == '/': case p[r] == '.' && p[r+1] == '/':
// . element // . element
r++ r += 2
case p[r] == '.' && p[r+1] == '.' && (r+2 == n || p[r+2] == '/'): case p[r] == '.' && p[r+1] == '.' && (r+2 == n || p[r+2] == '/'):
// .. element: remove to last / // .. element: remove to last /
r += 2 r += 3
if w > 1 { if w > 1 {
// can backtrack // can backtrack