aboutsummaryrefslogtreecommitdiff
path: root/lib/render.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/render.js')
-rw-r--r--lib/render.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/render.js b/lib/render.js
index d7fe04f..cc08259 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -136,7 +136,7 @@ Render.prototype.markdown = function (text, mentions) {
else if (link.host === 'http://localhost:7777')
mentionsObj[link.href] = link.link
if (link.link)
- mentionsByLink[link.link] = link
+ mentionsByLink[link.link + (link.key ? '#' + link.key : '')] = link
})
var out = marked(String(text), this.markedOpts)
delete this._mentions
@@ -147,6 +147,7 @@ Render.prototype.markdown = function (text, mentions) {
Render.prototype.imageUrl = function (ref) {
var m = /^blobstore:(.*)/.exec(ref)
if (m) ref = m[1]
+ ref = ref.replace(/#/, '%23')
return this.opts.img_base + 'image/' + ref
}
@@ -196,8 +197,14 @@ Render.prototype.toUrl = function (href) {
if (!u.isRef(href)) return false
return this.opts.base + href
case '&':
- if (!u.isRef(href)) return false
- return this.opts.blob_base + href
+ var parts = href.split('#')
+ var hash = parts.shift()
+ var key = parts.shift()
+ var fragment = parts.join('#')
+ if (!u.isRef(hash)) return false
+ return this.opts.blob_base + hash
+ + (key ? encodeURIComponent('#' + key) : '')
+ + (fragment ? '#' + fragment : '')
case '#': return this.opts.base + 'channel/' +
encodeURIComponent(href.substr(1))
case '/': return this.opts.base + href.substr(1)