GetShortNameFromURL处理图片URL中包含?号的情况

This commit is contained in:
gazebo
2019-09-26 10:54:32 +08:00
parent 3e6c031cd3
commit 60b141ef43

View File

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