1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-05-11 05:55:29 +00:00

static url

This commit is contained in:
Lunny Xiao
2019-03-14 10:20:40 +08:00
parent 2739a0be98
commit c559a9f824
8 changed files with 61 additions and 54 deletions

View File

@@ -104,6 +104,7 @@ var (
LetsEncryptTOS bool
LetsEncryptDirectory string
LetsEncryptEmail string
StaticURLPrefix string
SSH = struct {
Disabled bool `ini:"DISABLE_SSH"`
@@ -582,7 +583,7 @@ func NewContext() {
defaultAppURL += ":" + HTTPPort
}
AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL)
AppURL = strings.TrimRight(AppURL, "/") + "/"
AppURL = strings.TrimSuffix(AppURL, "/") + "/"
// Check if has app suburl.
appURL, err := url.Parse(AppURL)
@@ -592,6 +593,7 @@ func NewContext() {
// Suburl should start with '/' and end without '/', such as '/{subpath}'.
// This value is empty if site does not have sub-url.
AppSubURL = strings.TrimSuffix(appURL.Path, "/")
StaticURLPrefix = strings.TrimSuffix(sec.Key("STATIC_URL_PREFIX").MustString(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