Skip to content

Commit

Permalink
Fix go get response if only app URL is custom in configuration (#2634) (
Browse files Browse the repository at this point in the history
#2640)

* Fix go get response if only app URL is custom in configuration

* Rewrite to update Domain setting to match AppURL
  • Loading branch information
lafriks authored Oct 3, 2017
1 parent e38e502 commit 5b36379
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func Contexter() macaron.Handler {
</body>
</html>
`, map[string]string{
"GoGetImport": path.Join(setting.Domain, setting.AppSubURL, ctx.Link),
"GoGetImport": ComposeGoGetImport(ownerName, strings.TrimSuffix(repoName, ".git")),
"CloneLink": models.ComposeHTTPSCloneURL(ownerName, repoName),
"GoDocDirectory": prefix + "{/dir}",
"GoDocFile": prefix + "{/dir}/{file}#L{line}",
Expand Down
7 changes: 7 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"encoding/base64"
"fmt"
"io"
"net"
"net/mail"
"net/url"
"os"
Expand Down Expand Up @@ -657,6 +658,12 @@ func NewContext() {
// This value is empty if site does not have sub-url.
AppSubURL = strings.TrimSuffix(url.Path, "/")
AppSubURLDepth = strings.Count(AppSubURL, "/")
// Check if Domain differs from AppURL domain than update it to AppURL's domain
// TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8
urlHostname := strings.SplitN(url.Host, ":", 2)[0]
if urlHostname != Domain && net.ParseIP(urlHostname) == nil {
Domain = urlHostname
}

var defaultLocalURL string
switch Protocol {
Expand Down

0 comments on commit 5b36379

Please sign in to comment.