mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
path/filepath: change IsAbs to treat \\host\share as an absolute path
Fixes #47123 Change-Id: I2226b8a9ea24cd88171acfbaffea2566309416de Reviewed-on: https://go-review.googlesource.com/c/go/+/334809 Trust: Alex Brainman <alex.brainman@gmail.com> Trust: Hajime Hoshi <hajimehoshi@gmail.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
parent
946e2543f8
commit
8b471db71b
2 changed files with 6 additions and 0 deletions
|
|
@ -791,6 +791,8 @@ var winisabstests = []IsAbsTest{
|
||||||
{`c:a\b`, false},
|
{`c:a\b`, false},
|
||||||
{`c:\a\b`, true},
|
{`c:\a\b`, true},
|
||||||
{`c:/a/b`, true},
|
{`c:/a/b`, true},
|
||||||
|
{`\\host\share`, true},
|
||||||
|
{`\\host\share\`, true},
|
||||||
{`\\host\share\foo`, true},
|
{`\\host\share\foo`, true},
|
||||||
{`//host/share/foo/bar`, true},
|
{`//host/share/foo/bar`, true},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ func IsAbs(path string) (b bool) {
|
||||||
if l == 0 {
|
if l == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// If the volume name starts with a double slash, this is a UNC path.
|
||||||
|
if isSlash(path[0]) && isSlash(path[1]) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
path = path[l:]
|
path = path[l:]
|
||||||
if path == "" {
|
if path == "" {
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue