Fix path escaping on Windows

Windows does not allow ':' in a path, but for some reason previous
versions still worked, except the file for storing buffer info
(which had a ':' in the name) was not viewable except by opening
it with micro.

Ref #1736
This commit is contained in:
Zachary Yedidia
2020-06-27 17:59:28 -04:00
parent 3da0415ef1
commit f5c6f66c8f

View File

@@ -336,6 +336,10 @@ func GetModTime(path string) (time.Time, error) {
// EscapePath replaces every path separator in a given path with a %
func EscapePath(path string) string {
path = filepath.ToSlash(path)
if runtime.GOOS == "windows" {
// ':' is not valid in a path name on Windows but is ok on Unix
path = strings.Replace(path, ":", "%", -1)
}
return strings.Replace(path, "/", "%", -1)
}