@@ -144,20 +144,6 @@ func CustomLinkURLSchemes(schemes []string) {
144
144
common .LinkRegex , _ = xurls .StrictMatchingScheme (strings .Join (withAuth , "|" ))
145
145
}
146
146
147
- // IsSameDomain checks if given url string has the same hostname as current Gitea instance
148
- func IsSameDomain (s string ) bool {
149
- if strings .HasPrefix (s , "/" ) {
150
- return true
151
- }
152
- if uapp , err := url .Parse (setting .AppURL ); err == nil {
153
- if u , err := url .Parse (s ); err == nil {
154
- return u .Host == uapp .Host
155
- }
156
- return false
157
- }
158
- return false
159
- }
160
-
161
147
type postProcessError struct {
162
148
context string
163
149
err error
@@ -429,7 +415,7 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node) *html.Nod
429
415
// We ignore code and pre.
430
416
switch node .Type {
431
417
case html .TextNode :
432
- textNode (ctx , procs , node )
418
+ processTextNodes (ctx , procs , node )
433
419
case html .ElementNode :
434
420
if node .Data == "img" {
435
421
next := node .NextSibling
@@ -465,15 +451,16 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node) *html.Nod
465
451
for n := node .FirstChild ; n != nil ; {
466
452
n = visitNode (ctx , procs , n )
467
453
}
454
+ default :
468
455
}
469
456
return node .NextSibling
470
457
}
471
458
472
- // textNode runs the passed node through various processors, in order to handle
459
+ // processTextNodes runs the passed node through various processors, in order to handle
473
460
// all kinds of special links handled by the post-processing.
474
- func textNode (ctx * RenderContext , procs []processor , node * html.Node ) {
475
- for _ , processor := range procs {
476
- processor (ctx , node )
461
+ func processTextNodes (ctx * RenderContext , procs []processor , node * html.Node ) {
462
+ for _ , p := range procs {
463
+ p (ctx , node )
477
464
}
478
465
}
479
466
@@ -939,14 +926,11 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
939
926
// Path determines the type of link that will be rendered. It's unknown at this point whether
940
927
// the linked item is actually a PR or an issue. Luckily it's of no real consequence because
941
928
// Gitea will redirect on click as appropriate.
942
- path := "issues"
943
- if ref .IsPull {
944
- path = "pulls"
945
- }
929
+ issuePath := util .Iif (ref .IsPull , "pulls" , "issues" )
946
930
if ref .Owner == "" {
947
- link = createLink (util .URLJoin (ctx .Links .Prefix (), ctx .Metas ["user" ], ctx .Metas ["repo" ], path , ref .Issue ), reftext , "ref-issue" )
931
+ link = createLink (util .URLJoin (ctx .Links .Prefix (), ctx .Metas ["user" ], ctx .Metas ["repo" ], issuePath , ref .Issue ), reftext , "ref-issue" )
948
932
} else {
949
- link = createLink (util .URLJoin (ctx .Links .Prefix (), ref .Owner , ref .Name , path , ref .Issue ), reftext , "ref-issue" )
933
+ link = createLink (util .URLJoin (ctx .Links .Prefix (), ref .Owner , ref .Name , issuePath , ref .Issue ), reftext , "ref-issue" )
950
934
}
951
935
}
952
936
@@ -1207,7 +1191,7 @@ func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) {
1207
1191
return
1208
1192
}
1209
1193
ctx .AddCancel (func () {
1210
- closer .Close ()
1194
+ _ = closer .Close ()
1211
1195
ctx .GitRepo = nil
1212
1196
})
1213
1197
}
0 commit comments