Fix index out of range runtime error when provided string is empty

This commit is contained in:
Marcel Blijleven
2021-09-17 13:24:28 +02:00
parent 9a1ba21162
commit a2cbdfa976
2 changed files with 24 additions and 1 deletions

View File

@@ -51,9 +51,10 @@ func FixSlash(s string) string {
// FixSlashes appends and prepends a / if they are missing
func FixSlashes(s string) string {
if s[0] != '/' {
if !strings.HasPrefix(s, "/") {
s = "/" + s
}
return FixSlash(s)
}