Improve filepath resolution for relative paths
This commit is contained in:
6
util.go
6
util.go
@@ -27,13 +27,13 @@ func FileExists(path string) bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func NormalizePath(input string) string {
|
||||
workingdirectory, _ := os.Getwd()
|
||||
func NormalizePath(input, workdir string) string {
|
||||
input = filepath.ToSlash(input)
|
||||
input = strings.ReplaceAll(input, "\"", "")
|
||||
|
||||
if !filepath.IsAbs(input) {
|
||||
input = workingdirectory + "/" + input
|
||||
log.Printf("Input '%s' is not absolute, prepending work dir '%s'", input, workdir)
|
||||
input = workdir + "/" + input
|
||||
}
|
||||
|
||||
return filepath.Clean(input)
|
||||
|
Reference in New Issue
Block a user