fix: fixed bug for generating the upload file path

This commit is contained in:
RockYang
2023-10-05 18:09:42 +08:00
parent c5776ce41f
commit f971ec5d34
5 changed files with 31 additions and 7 deletions

View File

@@ -3,11 +3,15 @@ package main
import (
"fmt"
"net/url"
"path"
)
func main() {
parse, _ := url.Parse("http://localhost:5678/static")
imgURL := "https://www.baidu.com/static/upload/2023/10/1696497571220711277.png?ex=6530f4a2&is=651e7fa28hmFd709d069ca05d7855ebdae42e5aa436883a36f9310d546"
parse, err := url.Parse(imgURL)
if err != nil {
panic(err)
}
imgURLPrefix := fmt.Sprintf("%s://%s", parse.Scheme, parse.Host)
fmt.Println(imgURLPrefix)
fmt.Println(path.Ext(parse.Path))
}