@@ -21,12 +21,11 @@ import (
21
21
)
22
22
23
23
const (
24
- AppURL = "http://localhost:3000/"
25
- Repo = "gogits/gogs"
26
- AppSubURL = AppURL + Repo + "/"
24
+ AppURL = "http://localhost:3000/"
25
+ FullURL = AppURL + "gogits/gogs/"
27
26
)
28
27
29
- // these values should match the Repo const above
28
+ // these values should match the const above
30
29
var localMetas = map [string ]string {
31
30
"user" : "gogits" ,
32
31
"repo" : "gogs" ,
@@ -48,13 +47,12 @@ func TestMain(m *testing.M) {
48
47
49
48
func TestRender_StandardLinks (t * testing.T ) {
50
49
setting .AppURL = AppURL
51
- setting .AppSubURL = AppSubURL
52
50
53
51
test := func (input , expected , expectedWiki string ) {
54
52
buffer , err := RenderString (& markup.RenderContext {
55
53
Ctx : git .DefaultContext ,
56
54
Links : markup.Links {
57
- Base : setting . AppSubURL ,
55
+ Base : FullURL ,
58
56
},
59
57
}, input )
60
58
assert .NoError (t , err )
@@ -63,7 +61,7 @@ func TestRender_StandardLinks(t *testing.T) {
63
61
buffer , err = RenderString (& markup.RenderContext {
64
62
Ctx : git .DefaultContext ,
65
63
Links : markup.Links {
66
- Base : setting . AppSubURL ,
64
+ Base : FullURL ,
67
65
},
68
66
IsWiki : true ,
69
67
}, input )
@@ -74,22 +72,21 @@ func TestRender_StandardLinks(t *testing.T) {
74
72
googleRendered := `<p><a href="https://google.com/" rel="nofollow">https://google.com/</a></p>`
75
73
test ("<https://google.com/>" , googleRendered , googleRendered )
76
74
77
- lnk := util .URLJoin (AppSubURL , "WikiPage" )
78
- lnkWiki := util .URLJoin (AppSubURL , "wiki" , "WikiPage" )
75
+ lnk := util .URLJoin (FullURL , "WikiPage" )
76
+ lnkWiki := util .URLJoin (FullURL , "wiki" , "WikiPage" )
79
77
test ("[WikiPage](WikiPage)" ,
80
78
`<p><a href="` + lnk + `" rel="nofollow">WikiPage</a></p>` ,
81
79
`<p><a href="` + lnkWiki + `" rel="nofollow">WikiPage</a></p>` )
82
80
}
83
81
84
82
func TestRender_Images (t * testing.T ) {
85
83
setting .AppURL = AppURL
86
- setting .AppSubURL = AppSubURL
87
84
88
85
test := func (input , expected string ) {
89
86
buffer , err := RenderString (& markup.RenderContext {
90
87
Ctx : git .DefaultContext ,
91
88
Links : markup.Links {
92
- Base : setting . AppSubURL ,
89
+ Base : FullURL ,
93
90
},
94
91
}, input )
95
92
assert .NoError (t , err )
@@ -99,7 +96,7 @@ func TestRender_Images(t *testing.T) {
99
96
url := "../../.images/src/02/train.jpg"
100
97
title := "Train"
101
98
href := "https://gitea.io"
102
- result := util .URLJoin (AppSubURL , url )
99
+ result := util .URLJoin (FullURL , url )
103
100
// hint: With Markdown v2.5.2, there is a new syntax: [link](URL){:target="_blank"} , but we do not support it now
104
101
105
102
test (
@@ -289,15 +286,14 @@ This PR has been generated by [Renovate Bot](https://github.com/renovatebot/reno
289
286
290
287
func TestTotal_RenderWiki (t * testing.T ) {
291
288
setting .AppURL = AppURL
292
- setting .AppSubURL = AppSubURL
293
289
294
- answers := testAnswers (util .URLJoin (AppSubURL , "wiki" ), util .URLJoin (AppSubURL , "wiki" , "raw" ))
290
+ answers := testAnswers (util .URLJoin (FullURL , "wiki" ), util .URLJoin (FullURL , "wiki" , "raw" ))
295
291
296
292
for i := 0 ; i < len (sameCases ); i ++ {
297
293
line , err := RenderString (& markup.RenderContext {
298
294
Ctx : git .DefaultContext ,
299
295
Links : markup.Links {
300
- Base : setting . AppSubURL ,
296
+ Base : FullURL ,
301
297
},
302
298
Metas : localMetas ,
303
299
IsWiki : true ,
@@ -310,20 +306,20 @@ func TestTotal_RenderWiki(t *testing.T) {
310
306
// Guard wiki sidebar: special syntax
311
307
`[[Guardfile-DSL / Configuring-Guard|Guardfile-DSL---Configuring-Guard]]` ,
312
308
// rendered
313
- `<p><a href="` + AppSubURL + `wiki/Guardfile-DSL---Configuring-Guard" rel="nofollow">Guardfile-DSL / Configuring-Guard</a></p>
309
+ `<p><a href="` + FullURL + `wiki/Guardfile-DSL---Configuring-Guard" rel="nofollow">Guardfile-DSL / Configuring-Guard</a></p>
314
310
` ,
315
311
// special syntax
316
312
`[[Name|Link]]` ,
317
313
// rendered
318
- `<p><a href="` + AppSubURL + `wiki/Link" rel="nofollow">Name</a></p>
314
+ `<p><a href="` + FullURL + `wiki/Link" rel="nofollow">Name</a></p>
319
315
` ,
320
316
}
321
317
322
318
for i := 0 ; i < len (testCases ); i += 2 {
323
319
line , err := RenderString (& markup.RenderContext {
324
320
Ctx : git .DefaultContext ,
325
321
Links : markup.Links {
326
- Base : setting . AppSubURL ,
322
+ Base : FullURL ,
327
323
},
328
324
IsWiki : true ,
329
325
}, testCases [i ])
@@ -334,15 +330,14 @@ func TestTotal_RenderWiki(t *testing.T) {
334
330
335
331
func TestTotal_RenderString (t * testing.T ) {
336
332
setting .AppURL = AppURL
337
- setting .AppSubURL = AppSubURL
338
333
339
- answers := testAnswers (util .URLJoin (AppSubURL , "src" , "master" ), util .URLJoin (AppSubURL , "media" , "master" ))
334
+ answers := testAnswers (util .URLJoin (FullURL , "src" , "master" ), util .URLJoin (FullURL , "media" , "master" ))
340
335
341
336
for i := 0 ; i < len (sameCases ); i ++ {
342
337
line , err := RenderString (& markup.RenderContext {
343
338
Ctx : git .DefaultContext ,
344
339
Links : markup.Links {
345
- Base : AppSubURL ,
340
+ Base : FullURL ,
346
341
BranchPath : "master" ,
347
342
},
348
343
Metas : localMetas ,
@@ -357,7 +352,7 @@ func TestTotal_RenderString(t *testing.T) {
357
352
line , err := RenderString (& markup.RenderContext {
358
353
Ctx : git .DefaultContext ,
359
354
Links : markup.Links {
360
- Base : AppSubURL ,
355
+ Base : FullURL ,
361
356
},
362
357
}, testCases [i ])
363
358
assert .NoError (t , err )
0 commit comments