aboutsummaryrefslogtreecommitdiffstats
path: root/modules/markup/render_link.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/markup/render_link.go')
-rw-r--r--modules/markup/render_link.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/modules/markup/render_link.go b/modules/markup/render_link.go
index b2e0699681..046544ce81 100644
--- a/modules/markup/render_link.go
+++ b/modules/markup/render_link.go
@@ -33,10 +33,24 @@ func resolveLinkRelative(ctx context.Context, base, cur, link string, absolute b
return finalLink
}
-func (ctx *RenderContext) ResolveLinkRelative(base, cur, link string) (finalLink string) {
+func (ctx *RenderContext) ResolveLinkRelative(base, cur, link string) string {
+ if strings.HasPrefix(link, "/:") {
+ setting.PanicInDevOrTesting("invalid link %q, forgot to cut?", link)
+ }
return resolveLinkRelative(ctx, base, cur, link, ctx.RenderOptions.UseAbsoluteLink)
}
-func (ctx *RenderContext) ResolveLinkApp(link string) string {
+func (ctx *RenderContext) ResolveLinkRoot(link string) string {
return ctx.ResolveLinkRelative(setting.AppSubURL+"/", "", link)
}
+
+func ParseRenderedLink(s, preferLinkType string) (linkType, link string) {
+ if strings.HasPrefix(s, "/:") {
+ p := strings.IndexByte(s[1:], '/')
+ if p == -1 {
+ return s, ""
+ }
+ return s[:p+1], s[p+2:]
+ }
+ return preferLinkType, s
+}