mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Refactor markup render to fix various path problems (#34114)
* Fix #33972 * Use consistent path resolving for links and medias. * No need to make the markup renders to resolve the paths, instead, the paths are all correctly resolved in the "post process" step. * Fix #33274 * Since 1.23, all paths starting with "/" are relative to current render context (for example: the current repo branch) * Introduce `/:root/path-relative-to-root`, then the path will be rendered as relative to "ROOT_URL"
This commit is contained in:
		| @@ -15,8 +15,14 @@ type SimpleDocument struct { | ||||
| 	baseLink string | ||||
| } | ||||
|  | ||||
| func (r *SimpleDocument) ResolveLink(link string, likeType markup.LinkType) string { | ||||
| 	return r.ctx.ResolveLinkRelative(r.baseLink, "", link) | ||||
| func (r *SimpleDocument) ResolveLink(link, preferLinkType string) string { | ||||
| 	linkType, link := markup.ParseRenderedLink(link, preferLinkType) | ||||
| 	switch linkType { | ||||
| 	case markup.LinkTypeRoot: | ||||
| 		return r.ctx.ResolveLinkRoot(link) | ||||
| 	default: | ||||
| 		return r.ctx.ResolveLinkRelative(r.baseLink, "", link) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| var _ markup.RenderHelper = (*SimpleDocument)(nil) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user