@@ -425,6 +425,41 @@ func TestRender_ShortLinks(t *testing.T) {
425
425
`<p><a href="https://example.org" rel="nofollow">[[foobar]]</a></p>` )
426
426
}
427
427
428
+ func TestRender_RelativeImages (t * testing.T ) {
429
+ setting .AppURL = AppURL
430
+ setting .AppSubURL = AppSubURL
431
+ tree := util .URLJoin (AppSubURL , "src" , "master" )
432
+
433
+ test := func (input , expected , expectedUncyclo string ) {
434
+ buffer , err := markdown .RenderString (& RenderContext {
435
+ URLPrefix : tree ,
436
+ Metas : localMetas ,
437
+ }, input )
438
+ assert .NoError (t , err )
439
+ assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (buffer ))
440
+ buffer , err = markdown .RenderString (& RenderContext {
441
+ URLPrefix : setting .AppSubURL ,
442
+ Metas : localMetas ,
443
+ IsUncyclo : true ,
444
+ }, input )
445
+ assert .NoError (t , err )
446
+ assert .Equal (t , strings .TrimSpace (expectedUncyclo ), strings .TrimSpace (buffer ))
447
+ }
448
+
449
+ rawwiki := util .URLJoin (AppSubURL , "wiki" , "raw" )
450
+ mediatree := util .URLJoin (AppSubURL , "media" , "master" )
451
+
452
+ test (
453
+ `<img src="Link">` ,
454
+ `<img src="` + util .URLJoin (mediatree , "Link" )+ `"/>` ,
455
+ `<img src="` + util .URLJoin (rawwiki , "Link" )+ `"/>` )
456
+
457
+ test (
458
+ `<img src="./icon.png">` ,
459
+ `<img src="` + util .URLJoin (mediatree , "icon.png" )+ `"/>` ,
460
+ `<img src="` + util .URLJoin (rawwiki , "icon.png" )+ `"/>` )
461
+ }
462
+
428
463
func Test_ParseClusterFuzz (t * testing.T ) {
429
464
setting .AppURL = AppURL
430
465
setting .AppSubURL = AppSubURL
0 commit comments