From 29e2203ba1fece941161cf855f59dda468131127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8E=9A=E4=BC=9F?= Date: Mon, 11 Jan 2021 00:24:24 +0800 Subject: [PATCH] optimization bee pro gen url --- internal/app/module/beegopro/container.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/internal/app/module/beegopro/container.go b/internal/app/module/beegopro/container.go index 21bed30..2d2472f 100644 --- a/internal/app/module/beegopro/container.go +++ b/internal/app/module/beegopro/container.go @@ -3,6 +3,7 @@ package beegopro import ( "fmt" "io/ioutil" + "net/url" "strings" "sync" "time" @@ -242,10 +243,12 @@ func (c *Container) GetLocalPath() { if c.UserOption.GitRemotePath == "" { c.UserOption.GitRemotePath = "https://github.com/beego/beego-pro.git" } - url := c.UserOption.GitRemotePath - url = strings.TrimPrefix(url, "http://") - url = strings.TrimPrefix(url, "https://") - url = strings.TrimRight(url, ".git") - index := strings.Index(url, "/") - c.UserOption.GitLocalPath = system.BeegoHome + url[index:] + parse, err := url.Parse(c.UserOption.GitRemotePath) + if err != nil { + beeLogger.Log.Fatalf("git GitRemotePath err, %s", err.Error()) + return + } + s := parse.Path + s = strings.TrimRight(s, ".git") + c.UserOption.GitLocalPath = system.BeegoHome + s }