修复GetShortNameFromURL中的bug

This commit is contained in:
gazebo
2019-09-26 11:04:37 +08:00
parent 60b141ef43
commit 860040e6f1
2 changed files with 23 additions and 7 deletions

View File

@@ -733,14 +733,13 @@ func BatchString2Slice(strs ...string) (strList []string) {
}
func GetShortNameFromURL(strURL string) (shortName string) {
index := strings.LastIndex(strURL, "/")
index2 := strings.LastIndex(strURL, "?")
index := strings.Index(strURL, "?")
if index != -1 {
if index2 == -1 {
shortName = strURL[index+1:]
} else {
shortName = strURL[index+1 : index2]
}
strURL = strURL[:index]
}
index = strings.LastIndex(strURL, "/")
if index != -1 {
shortName = strURL[index+1:]
}
return shortName
}