diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo.go | 6 | ||||
-rw-r--r-- | routers/repo/repo.go | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/routers/api/v1/repo.go b/routers/api/v1/repo.go index 6bb78ba018..d7cc5955ab 100644 --- a/routers/api/v1/repo.go +++ b/routers/api/v1/repo.go @@ -196,9 +196,11 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) { } } - // Remote address can be HTTP/HTTPS URL or local path. + // Remote address can be HTTP/HTTPS/Git URL or local path. remoteAddr := form.CloneAddr - if strings.HasPrefix(form.CloneAddr, "http") { + if strings.HasPrefix(form.CloneAddr, "http://") || + strings.HasPrefix(form.CloneAddr, "https://") || + strings.HasPrefix(form.CloneAddr, "git://") { u, err := url.Parse(form.CloneAddr) if err != nil { ctx.HandleAPI(422, err) diff --git a/routers/repo/repo.go b/routers/repo/repo.go index d61917a081..73c9277d94 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -182,8 +182,12 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) { } // Remote address can be HTTP/HTTPS/Git URL or local path. + // Note: remember to change api/v1/repo.go: MigrateRepo + // FIXME: merge these two functions with better error handling remoteAddr := form.CloneAddr - if strings.HasPrefix(form.CloneAddr, "http://") || strings.HasPrefix(form.CloneAddr, "https://") || strings.HasPrefix(form.CloneAddr, "git://") { + if strings.HasPrefix(form.CloneAddr, "http://") || + strings.HasPrefix(form.CloneAddr, "https://") || + strings.HasPrefix(form.CloneAddr, "git://") { u, err := url.Parse(form.CloneAddr) if err != nil { ctx.Data["Err_CloneAddr"] = true |