Library: Trim "~" at the beginning and end of path names #3695

On Unix-like OS, this is a placeholder for the user's home directory.

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2023-09-20 17:31:01 +02:00
parent 8957462672
commit c2e38f942b

View File

@@ -38,7 +38,7 @@ func UserPath(dir string) string {
return dir return dir
} }
dir = strings.Trim(path.Clean(Path(strings.ReplaceAll(dir, "\\", "/"))), " ./\\|?*%<>") dir = strings.Trim(path.Clean(Path(strings.ReplaceAll(dir, "\\", "/"))), " ~./\\|?*%<>")
if strings.Contains(dir, "/.") || strings.Contains(dir, "..") || strings.Contains(dir, "//") { if strings.Contains(dir, "/.") || strings.Contains(dir, "..") || strings.Contains(dir, "//") {
return "" return ""