]> Cypherpunks repositories - gostls13.git/commitdiff
path/filepath: ignore dot for Dir(`\\server\share`)
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Wed, 25 Jan 2017 07:48:17 +0000 (16:48 +0900)
committerAlex Brainman <alex.brainman@gmail.com>
Sat, 4 Feb 2017 07:24:20 +0000 (07:24 +0000)
Dir(`\\server\share`) returns `\\server\share.`. Change Dir so it
returns `\\server\share` instead.

Fixes #18783

Change-Id: I9e0dd71ea6aea85e6c6114aaa4bb3bea3270d818
Reviewed-on: https://go-review.googlesource.com/35690
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/path/filepath/path.go
src/path/filepath/path_test.go

index 1d8e35c969e8810aaae51ace5f45b6c69460c150..e35ed5fefda79f44a4b1c60966d27a3ec2e7c83a 100644 (file)
@@ -461,6 +461,10 @@ func Dir(path string) string {
                i--
        }
        dir := Clean(path[len(vol) : i+1])
+       if dir == "." && len(vol) > 2 {
+               // must be UNC
+               return vol
+       }
        return vol + dir
 }
 
index 921b23842b458d732304103abe7f5d3e345e2d8c..70baa6112f6ca5a9d97004d8033891a501efe9c6 100644 (file)
@@ -665,6 +665,7 @@ var windirtests = []PathTest{
        {`c:\a\b`, `c:\a`},
        {`c:a\b`, `c:a`},
        {`c:a\b\c`, `c:a\b`},
+       {`\\host\share`, `\\host\share`},
        {`\\host\share\`, `\\host\share\`},
        {`\\host\share\a`, `\\host\share\`},
        {`\\host\share\a\b`, `\\host\share\a`},