From 4848620594ef96939887cba5aa278b1dc9321efb Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 31 Jan 2016 15:38:20 -0500 Subject: [PATCH] #2229 adjust URL verbose depth for reverse proxy sub-path --- README.md | 2 +- gogs.go | 2 +- modules/base/markdown.go | 4 +++- modules/setting/setting.go | 15 +++++++++------ templates/.VERSION | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 41fe2ebee7..edf6e94cbf 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true) -##### Current version: 0.8.25 +##### Current version: 0.8.26 | Web | UI | Preview | |:-------------:|:-------:|:-------:| diff --git a/gogs.go b/gogs.go index e4a007af5e..ed5565feb0 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.8.25.0131" +const APP_VER = "0.8.26.0131" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) 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" { diff --git a/templates/.VERSION b/templates/.VERSION index 93ddc737eb..c2a87b7c3a 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.8.25.0131 \ No newline at end of file +0.8.26.0131 \ No newline at end of file