From 6abd15e781377ae35cd139db92cdd8d44b77360c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 6 Feb 2023 16:12:31 +0100 Subject: Adjust tests for GO 1.20 Updates #10691 --- common/paths/path.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'common/paths/path.go') diff --git a/common/paths/path.go b/common/paths/path.go index 11d221bb1..f1992f196 100644 --- a/common/paths/path.go +++ b/common/paths/path.go @@ -100,25 +100,25 @@ var isFileRe = regexp.MustCompile(`.*\..{1,6}$`) // GetDottedRelativePath expects a relative path starting after the content directory. // It returns a relative path with dots ("..") navigating up the path structure. func GetDottedRelativePath(inPath string) string { - inPath = filepath.Clean(filepath.FromSlash(inPath)) + inPath = path.Clean(filepath.ToSlash(inPath)) if inPath == "." { return "./" } - if !isFileRe.MatchString(inPath) && !strings.HasSuffix(inPath, FilePathSeparator) { - inPath += FilePathSeparator + if !isFileRe.MatchString(inPath) && !strings.HasSuffix(inPath, "/") { + inPath += "/" } - if !strings.HasPrefix(inPath, FilePathSeparator) { - inPath = FilePathSeparator + inPath + if !strings.HasPrefix(inPath, "/") { + inPath = "/" + inPath } dir, _ := filepath.Split(inPath) - sectionCount := strings.Count(dir, FilePathSeparator) + sectionCount := strings.Count(dir, "/") - if sectionCount == 0 || dir == FilePathSeparator { + if sectionCount == 0 || dir == "/" { return "./" } -- cgit v1.2.3