aboutsummaryrefslogtreecommitdiff
path: root/lib/render.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-09-29 08:41:55 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-09-29 08:41:55 -1000
commit440274d19f302e0f293d56cba685e39e372cda12 (patch)
tree5bcd754ab04f5080aaf353dfc2b60b5fac7edb31 /lib/render.js
parent7fffac329b2718f0ea918cd9fd53d3e2b47cc93e (diff)
parent62e7e74bd278473cc4358700b7f2b5c0a78ac681 (diff)
downloadpatchfoo-440274d19f302e0f293d56cba685e39e372cda12.tar.gz
patchfoo-440274d19f302e0f293d56cba685e39e372cda12.zip
Merge branch 'secretblobs' into master
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)