@@ -10,26 +10,20 @@ import (
10
10
"code.gitea.io/gitea/modules/git"
11
11
"code.gitea.io/gitea/modules/markup"
12
12
"code.gitea.io/gitea/modules/setting"
13
- "code.gitea.io/gitea/modules/util"
14
13
15
14
"github.com/stretchr/testify/assert"
16
15
)
17
16
18
- const (
19
- AppURL = "http://localhost:3000/"
20
- Repo = "gogits/gogs"
21
- AppSubURL = AppURL + Repo + "/"
22
- )
17
+ const AppURL = "http://localhost:3000/"
23
18
24
19
func TestRender_StandardLinks (t * testing.T ) {
25
20
setting .AppURL = AppURL
26
- setting .AppSubURL = AppSubURL
27
21
28
22
test := func (input , expected string ) {
29
23
buffer , err := RenderString (& markup.RenderContext {
30
24
Ctx : git .DefaultContext ,
31
25
Links : markup.Links {
32
- Base : setting . AppSubURL ,
26
+ Base : "/relative-path" ,
33
27
},
34
28
}, input )
35
29
assert .NoError (t , err )
@@ -39,31 +33,28 @@ func TestRender_StandardLinks(t *testing.T) {
39
33
test ("[[https://google.com/]]" ,
40
34
`<p><a href="https://google.com/">https://google.com/</a></p>` )
41
35
42
- lnk := util .URLJoin (AppSubURL , "WikiPage" )
43
- test ("[[WikiPage][WikiPage]]" ,
44
- `<p><a href="` + lnk + `">WikiPage</a></p>` )
36
+ test ("[[WikiPage][The WikiPage Name]]" ,
37
+ `<p><a href="/relative-path/WikiPage">The WikiPage Name</a></p>` )
45
38
}
46
39
47
40
func TestRender_Media (t * testing.T ) {
48
41
setting .AppURL = AppURL
49
- setting .AppSubURL = AppSubURL
50
42
51
43
test := func (input , expected string ) {
52
44
buffer , err := RenderString (& markup.RenderContext {
53
45
Ctx : git .DefaultContext ,
54
46
Links : markup.Links {
55
- Base : setting . AppSubURL ,
47
+ Base : "./relative-path" ,
56
48
},
57
49
}, input )
58
50
assert .NoError (t , err )
59
51
assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (buffer ))
60
52
}
61
53
62
- url := "../../.images/src/02/train.jpg"
63
- result := util .URLJoin (AppSubURL , url )
64
-
65
- test ("[[file:" + url + "]]" ,
66
- `<p><img src="` + result + `" alt="` + result + `" /></p>` )
54
+ test ("[[file:../../.images/src/02/train.jpg]]" ,
55
+ `<p><img src=".images/src/02/train.jpg" alt=".images/src/02/train.jpg" /></p>` )
56
+ test ("[[file:train.jpg]]" ,
57
+ `<p><img src="relative-path/train.jpg" alt="relative-path/train.jpg" /></p>` )
67
58
68
59
// With description.
69
60
test ("[[https://example.com][https://example.com/example.svg]]" ,
@@ -94,7 +85,6 @@ func TestRender_Media(t *testing.T) {
94
85
95
86
func TestRender_Source (t * testing.T ) {
96
87
setting .AppURL = AppURL
97
- setting .AppSubURL = AppSubURL
98
88
99
89
test := func (input , expected string ) {
100
90
buffer , err := RenderString (& markup.RenderContext {
0 commit comments