Files
zurg/internal/dav/util.go
2024-07-21 03:32:16 +02:00

23 lines
467 B
Go

package dav
import (
"strings"
)
// addSlash ensures the input string ends with a slash regardless of the OS
func addSlash(input string) string {
// Standardize the path separator to use forward slashes
input = strings.ReplaceAll(input, "\\", "/")
// Ensure the input starts with a slash
if !strings.HasPrefix(input, "/") {
input = "/" + input
}
// Ensure the path ends with a slash
if !strings.HasSuffix(input, "/") {
input += "/"
}
return input
}