From 3234c28f7c45d539b44f53a828233632b9cc5343 Mon Sep 17 00:00:00 2001 From: klauspost Date: Thu, 17 Sep 2015 11:50:41 +0200 Subject: [PATCH] Minor adjustments to Unc path conversion function. --- local/local.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/local/local.go b/local/local.go index 72d5001c2..e8a23fb80 100644 --- a/local/local.go +++ b/local/local.go @@ -638,8 +638,8 @@ func filterPath(s string) string { return s } -// Pattern to match a windows absolute path: c:\temp path. -var isAbsWinDrive = regexp.MustCompile(`[a-zA-Z]\:\\`) +// Pattern to match a windows absolute path: "c:\" and similar +var isAbsWinDrive = regexp.MustCompile(`^[a-zA-Z]\:\\`) // uncPath converts an absolute Windows path // to a UNC long path. @@ -653,10 +653,11 @@ func uncPath(s string) string { if strings.HasPrefix(s, `\\?\`) { return s } - // Trim "//" from path and add UNC prefix. + + // Trim "\\" from path and add UNC prefix. return `\\?\UNC\` + strings.TrimPrefix(s, `\\`) } - if isAbsWinDrive.Match([]byte(s)) { + if isAbsWinDrive.MatchString(s) { return `\\?\` + s } return s