1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Handle insecure and ports in go get (#7041)

* Handle insecure and ports in go get

* Fix IsExternalURL for non-standard ports
This commit is contained in:
zeripath
2019-05-27 22:08:38 +01:00
committed by GitHub
parent 9ca7fcddbb
commit 69d81b6569
4 changed files with 16 additions and 4 deletions

View File

@@ -257,6 +257,13 @@ func Contexter() macaron.Handler {
branchName = repo.DefaultBranch
}
prefix := setting.AppURL + path.Join(url.PathEscape(ownerName), url.PathEscape(repoName), "src", "branch", util.PathEscapeSegments(branchName))
appURL, _ := url.Parse(setting.AppURL)
insecure := ""
if appURL.Scheme == string(setting.HTTP) {
insecure = "--insecure "
}
c.Header().Set("Content-Type", "text/html")
c.WriteHeader(http.StatusOK)
c.Write([]byte(com.Expand(`<!doctype html>
@@ -266,7 +273,7 @@ func Contexter() macaron.Handler {
<meta name="go-source" content="{GoGetImport} _ {GoDocDirectory} {GoDocFile}">
</head>
<body>
go get {GoGetImport}
go get {Insecure}{GoGetImport}
</body>
</html>
`, map[string]string{
@@ -274,6 +281,7 @@ func Contexter() macaron.Handler {
"CloneLink": models.ComposeHTTPSCloneURL(ownerName, repoName),
"GoDocDirectory": prefix + "{/dir}",
"GoDocFile": prefix + "{/dir}/{file}#L{line}",
"Insecure": insecure,
})))
return
}