diff --git a/cleanpath_benchmark_test.go b/cleanpath_benchmark_test.go index ee8e4251..6741e9f7 100644 --- a/cleanpath_benchmark_test.go +++ b/cleanpath_benchmark_test.go @@ -116,7 +116,9 @@ func BenchmarkCleanPath(b *testing.B) { "/abc/def/..", "/abc/def/../..", "/abc/def/../../..", "/abc/def/../../..", "/abc/def/../../../ghi/jkl/../../../mno", + "abc/..def", "abc/./...", "abc/a../...", "abc/a..z", "abc/./../def", "abc//./../def", "abc/../../././../def", + "abc/./../..def", "abc/../.../..def", "abc/.//../..def", } for _, function := range functions { diff --git a/path_test.go b/path_test.go index c1e6ed4f..f20150ae 100644 --- a/path_test.go +++ b/path_test.go @@ -60,10 +60,20 @@ var cleanTests = []struct { {"/abc/def/../../..", "/"}, {"/abc/def/../../../ghi/jkl/../../../mno", "/mno"}, + // Keep .. elements + {"abc/..def", "/abc/..def"}, + {"abc/./...", "/abc/..."}, + {"abc/a../...", "/abc/a../..."}, + {"abc/a..z", "/abc/a..z"}, + // Combinations {"abc/./../def", "/def"}, {"abc//./../def", "/def"}, {"abc/../../././../def", "/def"}, + {"abc/../../././../...", "/..."}, + {"abc/./../..def", "/..def"}, + {"abc/../.../..def", "/.../..def"}, + {"abc/.//../..def", "/..def"}, } func TestPathClean(t *testing.T) {