aboutsummaryrefslogtreecommitdiff
path: root/src/path/filepath/path.go
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@google.com>2022-06-01 17:42:39 +0000
committerDmitri Shuralyov <dmitshur@google.com>2022-06-01 17:42:39 +0000
commit4658e6e324a85b0076f66acdab77799ffa9ac7bb (patch)
treef3b4de12074d583057060fdf35d91b6591859644 /src/path/filepath/path.go
parent6b07de790c08967d0dbe3a36ec86f3d13e1cfcbd (diff)
parent26cdea3acca29db94541236f0037a20aa22ce2d7 (diff)
downloadgo-4658e6e324a85b0076f66acdab77799ffa9ac7bb.tar.gz
go-4658e6e324a85b0076f66acdab77799ffa9ac7bb.zip
[dev.boringcrypto.go1.17] all: merge go1.17.11 into dev.boringcrypto.go1.17
Change-Id: I563433b2d02a5abea610a1561139d0980d5c2102
Diffstat (limited to 'src/path/filepath/path.go')
-rw-r--r--src/path/filepath/path.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go
index b56534dead..8300a32cb1 100644
--- a/src/path/filepath/path.go
+++ b/src/path/filepath/path.go
@@ -117,9 +117,21 @@ func Clean(path string) string {
case os.IsPathSeparator(path[r]):
// empty path element
r++
- case path[r] == '.' && (r+1 == n || os.IsPathSeparator(path[r+1])):
+ case path[r] == '.' && r+1 == n:
// . element
r++
+ case path[r] == '.' && os.IsPathSeparator(path[r+1]):
+ // ./ element
+ r++
+
+ for r < len(path) && os.IsPathSeparator(path[r]) {
+ r++
+ }
+ if out.w == 0 && volumeNameLen(path[r:]) > 0 {
+ // When joining prefix "." and an absolute path on Windows,
+ // the prefix should not be removed.
+ out.append('.')
+ }
case path[r] == '.' && path[r+1] == '.' && (r+2 == n || os.IsPathSeparator(path[r+2])):
// .. element: remove to last separator
r += 2