diff options
author | Unknwon <u@gogs.io> | 2016-01-31 15:38:20 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-01-31 15:38:20 -0500 |
commit | 4848620594ef96939887cba5aa278b1dc9321efb (patch) | |
tree | 56b3c95d1df8e4e05cbb1fa17611024040f3f5dc /modules | |
parent | 57c10aae33c6231470578e2e1f1dce59cfd306f8 (diff) | |
download | gitea-4848620594ef96939887cba5aa278b1dc9321efb.tar.gz gitea-4848620594ef96939887cba5aa278b1dc9321efb.zip |
#2229 adjust URL verbose depth for reverse proxy sub-path
Diffstat (limited to 'modules')
-rw-r--r-- | modules/base/markdown.go | 4 | ||||
-rw-r--r-- | modules/setting/setting.go | 15 |
2 files changed, 12 insertions, 7 deletions
diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 0ef379b8ed..265deffa3e 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -21,6 +21,8 @@ import ( "github.com/gogits/gogs/modules/setting" ) +// TODO: put this into 'markdown' module. + func isletter(c byte) bool { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') } @@ -187,7 +189,7 @@ func cutoutVerbosePrefix(prefix string) string { if prefix[i] == '/' { count++ } - if count >= 3 { + if count >= 3+setting.AppSubUrlDepth { return prefix[:i] } } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 052ec377e6..3936546ca6 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -48,12 +48,13 @@ var ( BuildGitHash string // App settings - AppVer string - AppName string - AppUrl string - AppSubUrl string - AppPath string - AppDataPath = "data" + AppVer string + AppName string + AppUrl string + AppSubUrl string + AppSubUrlDepth int // Number of slashes + AppPath string + AppDataPath = "data" // Server settings Protocol Scheme @@ -299,7 +300,9 @@ func NewContext() { if err != nil { log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppUrl, err) } + // Suburl should start with '/' and end without '/', such as '/{subpath}'. AppSubUrl = strings.TrimSuffix(url.Path, "/") + AppSubUrlDepth = strings.Count(AppSubUrl, "/") Protocol = HTTP if sec.Key("PROTOCOL").String() == "https" { |