aboutsummaryrefslogtreecommitdiff
path: root/src/path/filepath/path.go
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2018-10-15 17:09:34 -0400
committerFilippo Valsorda <filippo@golang.org>2018-10-15 17:09:34 -0400
commit623650b27aa42dd2ccd20fc4a79f8fe7b8559987 (patch)
treebfafa16d1bfd57fc1d9831c22e6e236be3d52281 /src/path/filepath/path.go
parent36c789b1fd72af5ff6e756794597a3a85e069998 (diff)
parent1961d8d72a53e780effa18bfa8dbe4e4282df0b2 (diff)
downloadgo-623650b27aa42dd2ccd20fc4a79f8fe7b8559987.tar.xz
[dev.boringcrypto] all: merge master into dev.boringcrypto
Change-Id: I218ba1b89a2df6e4335c6a5846889d9a04affe5d
Diffstat (limited to 'src/path/filepath/path.go')
-rw-r--r--src/path/filepath/path.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go
index 1508137a33..bbb90306a7 100644
--- a/src/path/filepath/path.go
+++ b/src/path/filepath/path.go
@@ -96,14 +96,19 @@ 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 buf; w is index of next byte to write.
- // dotdot is index in buf where .. must stop, either because
+ // writing to out; w is index of next byte to write.
+ // dotdot is index in out 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 {
@@ -166,7 +171,7 @@ func ToSlash(path string) string {
if Separator == '/' {
return path
}
- return strings.Replace(path, string(Separator), "/", -1)
+ return strings.ReplaceAll(path, string(Separator), "/")
}
// FromSlash returns the result of replacing each slash ('/') character
@@ -176,7 +181,7 @@ func FromSlash(path string) string {
if Separator == '/' {
return path
}
- return strings.Replace(path, "/", string(Separator), -1)
+ return strings.ReplaceAll(path, "/", string(Separator))
}
// SplitList splits a list of paths joined by the OS-specific ListSeparator,