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