Fix some edge cases; closes #3232
- Fixes wrong usage of AppURL - Fixes wrong rendering with extra path segments when AppSubURL is empty - Now also renders all links when 2+ permalinks are present
This commit is contained in:
parent
e4aa7bd511
commit
5b6b3f3fb3
3 changed files with 191 additions and 79 deletions
|
@ -56,11 +56,11 @@ func NewFilePreview(ctx *RenderContext, node *html.Node, locale translation.Loca
|
|||
urlFull := node.Data[m[0]:m[1]]
|
||||
|
||||
// Ensure that we only use links to local repositories
|
||||
if !strings.HasPrefix(urlFull, setting.AppURL+setting.AppSubURL) {
|
||||
if !strings.HasPrefix(urlFull, setting.AppURL) {
|
||||
return nil
|
||||
}
|
||||
|
||||
projPath := strings.TrimSuffix(node.Data[m[2]:m[3]], "/")
|
||||
projPath := strings.TrimPrefix(strings.TrimSuffix(node.Data[m[0]:m[3]], "/"), setting.AppURL)
|
||||
|
||||
commitSha := node.Data[m[4]:m[5]]
|
||||
filePath := node.Data[m[6]:m[7]]
|
||||
|
@ -70,6 +70,10 @@ func NewFilePreview(ctx *RenderContext, node *html.Node, locale translation.Loca
|
|||
preview.end = m[1]
|
||||
|
||||
projPathSegments := strings.Split(projPath, "/")
|
||||
if len(projPathSegments) != 2 {
|
||||
return nil
|
||||
}
|
||||
|
||||
ownerName := projPathSegments[len(projPathSegments)-2]
|
||||
repoName := projPathSegments[len(projPathSegments)-1]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue