slash method fixed

This commit is contained in:
alessio 2016-08-22 00:56:19 +02:00
parent 562ced11ab
commit c86a2c9a18
1 changed files with 2 additions and 2 deletions

View File

@ -226,7 +226,7 @@ func inArray(str string, list []string) bool {
// add a slash at the beginning if not exist // add a slash at the beginning if not exist
func slash(str string) string { func slash(str string) string {
if string(str[0]) != "/" { if len(str) == 0 || string(str[0]) != "/" {
str = "/" + str str = "/" + str
} }
if string(str[len(str)-1]) == "/" { if string(str[len(str)-1]) == "/" {
@ -235,7 +235,7 @@ func slash(str string) string {
} else if string(str) == "/" { } else if string(str) == "/" {
str = "" str = ""
} else { } else {
str = str[0 : len(str)-2] str = str[0 : len(str)-1]
} }
} }
return str return str