aboutsummaryrefslogtreecommitdiff
path: root/src/path
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-02-19 18:12:13 -0800
committerIan Lance Taylor <iant@golang.org>2019-02-20 18:32:07 +0000
commit153c0da89bca6726545cf4451053235b552d3d51 (patch)
tree25a076f1178c58e2600ee605d4780ad3460f1d9e /src/path
parentdace6544b3ff077d8cc02fc37d59187be253ab70 (diff)
downloadgo-153c0da89bca6726545cf4451053235b552d3d51.tar.gz
go-153c0da89bca6726545cf4451053235b552d3d51.zip
path/filepath: revert "fix Windows-specific Clean bug"
Revert CL 137055, which changed Clean("\\somepath\dir\") to return "\\somepath\dir" on Windows. It's not entirely clear this is correct, as this path is really "\\server\share\", and as such the trailing slash may be the path on that share, much like "C:\". In any case, the change broke existing code, so roll it back for now and rethink for 1.13. Updates #27791 Fixes #30307 Change-Id: I69200b1efe38bdb6d452b744582a2bfbb3acbcec Reviewed-on: https://go-review.googlesource.com/c/163077 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/path')
-rw-r--r--src/path/filepath/path.go11
-rw-r--r--src/path/filepath/path_test.go3
2 files changed, 3 insertions, 11 deletions
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go
index bbb90306a7..aba1717e7d 100644
--- a/src/path/filepath/path.go
+++ b/src/path/filepath/path.go
@@ -96,19 +96,14 @@ func Clean(path string) string {
}
return originalPath + "."
}
-
- n := len(path)
- if volLen > 2 && n == 1 && os.IsPathSeparator(path[0]) {
- // UNC volume name with trailing slash.
- return FromSlash(originalPath[:volLen])
- }
rooted := os.IsPathSeparator(path[0])
// Invariants:
// reading from path; r is index of next byte to process.
- // writing to out; w is index of next byte to write.
- // dotdot is index in out where .. must stop, either because
+ // writing to buf; w is index of next byte to write.
+ // dotdot is index in buf where .. must stop, either because
// it is the leading slash or it is a leading ../../.. prefix.
+ n := len(path)
out := lazybuf{path: path, volAndPath: originalPath, volLen: volLen}
r, dotdot := 0, 0
if rooted {
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go
index 9c4c7ebedc..7a434a4292 100644
--- a/src/path/filepath/path_test.go
+++ b/src/path/filepath/path_test.go
@@ -93,9 +93,6 @@ var wincleantests = []PathTest{
{`//host/share/foo/../baz`, `\\host\share\baz`},
{`\\a\b\..\c`, `\\a\b\c`},
{`\\a\b`, `\\a\b`},
- {`\\a\b\`, `\\a\b`},
- {`\\folder\share\foo`, `\\folder\share\foo`},
- {`\\folder\share\foo\`, `\\folder\share\foo`},
}
func TestClean(t *testing.T) {