23 lines
467 B
Go
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
|
|
}
|