aboutsummaryrefslogtreecommitdiff
path: root/lib/render.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-25 16:06:28 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-26 13:40:38 -1000
commit62e7e74bd278473cc4358700b7f2b5c0a78ac681 (patch)
tree8519cd1fbf0bb3827922f59646d28fe6258768df /lib/render.js
parent6dbfedff2f7246430f4e6da100bc3baed0ef4ce1 (diff)
downloadpatchfoo-62e7e74bd278473cc4358700b7f2b5c0a78ac681.tar.gz
patchfoo-62e7e74bd278473cc4358700b7f2b5c0a78ac681.zip
Encrypt blobs in private messages
Diffstat (limited to 'lib/render.js')
-rw-r--r--lib/render.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/render.js b/lib/render.js
index dd6d55e..3b4a142 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -129,6 +129,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 + ref
}
@@ -161,8 +162,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)