aboutsummaryrefslogtreecommitdiffhomepage
path: root/helpers
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-02-06 16:12:31 +0100
committerBjørn Erik Pedersen <[email protected]>2023-02-22 11:26:52 +0100
commit6abd15e781377ae35cd139db92cdd8d44b77360c (patch)
treeac4a596e86a10f24c7c3975e1b91b7e8d16b91f5 /helpers
parent094135ff96c8f7a0951f66a2a1f82371b76e143f (diff)
downloadhugo-6abd15e781377ae35cd139db92cdd8d44b77360c.tar.gz
hugo-6abd15e781377ae35cd139db92cdd8d44b77360c.zip
Adjust tests for GO 1.20
Updates #10691
Diffstat (limited to 'helpers')
-rw-r--r--helpers/path.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/helpers/path.go b/helpers/path.go
index b3f69ff90..7bc216ec8 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -18,6 +18,7 @@ import (
"fmt"
"io"
"os"
+ "path"
"path/filepath"
"regexp"
"sort"
@@ -142,25 +143,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)
+ dir, _ := path.Split(inPath)
- sectionCount := strings.Count(dir, FilePathSeparator)
+ sectionCount := strings.Count(dir, "/")
- if sectionCount == 0 || dir == FilePathSeparator {
+ if sectionCount == 0 || dir == "/" {
return "./"
}