fix: 校验参数,解析url出错时不退出主线程
This commit is contained in:
fengxxc
2023-07-16 18:07:55 +08:00
parent 62d25cd4eb
commit a95dc2ae5c
3 changed files with 3 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
BUILD_ENV := CGO_ENABLED=0
APP=wechatmp2markdown
VERSION=v1.1.1
VERSION=v1.1.2
# linux or mac 环境编译
# make [cmd]

View File

@@ -35,7 +35,7 @@ func main() {
// --image=save -is 保存图片,最终输出到文件夹
// --save=zip -sz 最终打包输出到zip
imageArgValue := "base64"
if args[3] != "" {
if len(args) > 3 && args[3] != "" {
if strings.HasPrefix(args[3], "--image=") {
imageArgValue = args[3][len("--image="):]
} else if strings.HasPrefix(args[3], "-i") {

View File

@@ -196,7 +196,7 @@ func ParseFromHTMLFile(filepath string, imagePolicy ImagePolicy) Article {
func ParseFromURL(url string, imagePolicy ImagePolicy) Article {
res, err := http.Get(url)
if err != nil {
panic(err)
log.Fatalf(err.Error())
}
defer res.Body.Close()
if res.StatusCode != 200 {