fix: local relative path

This commit is contained in:
Noah Hsu
2022-06-27 20:37:05 +08:00
parent 7c0b86a9cd
commit 74973bc5b5
6 changed files with 25 additions and 5 deletions

View File

@ -2,7 +2,6 @@ package utils
import (
"path/filepath"
"runtime"
"strings"
)
@ -10,11 +9,11 @@ import (
func StandardizePath(path string) string {
path = strings.TrimSuffix(path, "/")
// windows abs path
if filepath.IsAbs(path) && runtime.GOOS == "windows" {
if filepath.IsAbs(path) {
return path
}
// relative path with prefix '..'
if strings.HasPrefix(path, "..") {
if strings.HasPrefix(path, ".") {
return path
}
if !strings.HasPrefix(path, "/") {