Fix go get response if only app URL is custom in configuration (#2634)
* Fix go get response if only app URL is custom in configuration * Rewrite to update Domain setting to match AppURL
This commit is contained in:
parent
a8717e5e3a
commit
46cc45f049
|
@ -194,7 +194,7 @@ func Contexter() macaron.Handler {
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`, map[string]string{
|
`, map[string]string{
|
||||||
"GoGetImport": path.Join(setting.Domain, setting.AppSubURL, ctx.Link),
|
"GoGetImport": ComposeGoGetImport(ownerName, strings.TrimSuffix(repoName, ".git")),
|
||||||
"CloneLink": models.ComposeHTTPSCloneURL(ownerName, repoName),
|
"CloneLink": models.ComposeHTTPSCloneURL(ownerName, repoName),
|
||||||
"GoDocDirectory": prefix + "{/dir}",
|
"GoDocDirectory": prefix + "{/dir}",
|
||||||
"GoDocFile": prefix + "{/dir}/{file}#L{line}",
|
"GoDocFile": prefix + "{/dir}/{file}#L{line}",
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
@ -664,6 +665,12 @@ func NewContext() {
|
||||||
// This value is empty if site does not have sub-url.
|
// This value is empty if site does not have sub-url.
|
||||||
AppSubURL = strings.TrimSuffix(url.Path, "/")
|
AppSubURL = strings.TrimSuffix(url.Path, "/")
|
||||||
AppSubURLDepth = strings.Count(AppSubURL, "/")
|
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
|
var defaultLocalURL string
|
||||||
switch Protocol {
|
switch Protocol {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user