]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Adjust tests for GO 1.20
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 6 Feb 2023 15:12:31 +0000 (16:12 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 22 Feb 2023 10:26:52 +0000 (11:26 +0100)
Updates #10691

common/paths/path.go
helpers/path.go

index 11d221bb153ff94d03118f0247b1d464844c1b13..f1992f196cd638739a14f666e1ea21ac4fa7e200 100644 (file)
@@ -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 "./"
        }
 
index b3f69ff90c64c25a8bac4809336be38bcd4e16ce..7bc216ec813d2e3f2fea1545bd9b5cdc6f64df05 100644 (file)
@@ -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 "./"
        }