Commit a61f3a4f15d549be32ee33146be221e1f525cea3
include contentType in request url for embedded blobs
allows for embedded video/audio and sets correct mime typeMatt McKegg committed on 4/13/2018, 5:54:32 AM
Parent: 6c7863e4b2ff580dd8b633623387fb444ccd5256
Files changed
message/html/markdown.js | changed |
message/html/markdown.js | ||
---|---|---|
@@ -19,11 +19,15 @@ | ||
19 | 19 … | function markdown (content) { |
20 | 20 … | if (typeof content === 'string') { content = {text: content} } |
21 | 21 … | // handle patchwork style mentions and custom emoji. |
22 | 22 … | var mentions = {} |
23 … | + var typeLookup = {} | |
23 | 24 … | var emojiMentions = {} |
24 | 25 … | if (Array.isArray(content.mentions)) { |
25 | 26 … | content.mentions.forEach(function (link) { |
27 … | + if (link && link.link && link.type) { | |
28 … | + typeLookup[link.link] = link.type | |
29 … | + } | |
26 | 30 … | if (link && link.name && link.link) { |
27 | 31 … | if (link.emoji) emojiMentions[link.name] = link.link |
28 | 32 … | else mentions['@' + link.name] = link.link |
29 | 33 … | } |
@@ -41,9 +45,18 @@ | ||
41 | 45 … | : api.emoji.sync.url(emoji) |
42 | 46 … | return renderEmoji(emoji, url) |
43 | 47 … | }, |
44 | 48 … | toUrl: (id) => { |
45 | - if (id.startsWith('&')) return api.blob.sync.url(id) | |
49 … | + if (id.startsWith('&')) { | |
50 … | + var url = api.blob.sync.url(id) | |
51 … | + | |
52 … | + if (typeLookup[id]) { | |
53 … | + var separator = url.includes('?') ? '&' : '?' | |
54 … | + url += separator + 'contentType=' + escape(typeLookup[id]) | |
55 … | + } | |
56 … | + | |
57 … | + return url | |
58 … | + } | |
46 | 59 … | if (mentions[id]) { |
47 | 60 … | return mentions[id] |
48 | 61 … | } else if (ref.isLink(id) || id.startsWith('#') || id.startsWith('?')) { |
49 | 62 … | return id |
Built with git-ssb-web