git ssb

9+

cel / ssb-viewer



Commit a606674d3015f7f239614695ba937bc8d8bf6226

merge with @cel

Anders Rune Jensen committed on 4/17/2017, 6:44:33 AM
Parent: 5c13d7dc8dd9c1117f5e31633ddb3e5858ee474c
Parent: 7b1296a17c686246a78705ff9f4d90b54c294c86

Files changed

index.jschanged
index.jsView
@@ -17,9 +17,9 @@
1717
1818 var emojiDir = path.join(require.resolve('emoji-named-characters'), '../pngs')
1919 var appHash = hash([fs.readFileSync(__filename)])
2020
21-var urlIdRegex = /^(?:\/(([%&]|%25)(?:[A-Za-z0-9\/+]|%2[Ff]|%2[Bb]){43}(?:=|%3[Dd])\.sha256)(?:\.([^?]*))?|(\/.*?))(?:\?(.*))?$/
21 +var urlIdRegex = /^(?:\/(([%&@]|%25|%26|%40)(?:[A-Za-z0-9\/+]|%2[Ff]|%2[Bb]){43}(?:=|%3[Dd])\.(?:sha256|ed25519))(?:\.([^?]*))?|(\/.*?))(?:\?(.*))?$/
2222
2323 function MdRenderer(opts) {
2424 marked.Renderer.call(this, {})
2525 this.opts = opts
@@ -85,22 +85,24 @@
8585 }
8686
8787 var m = urlIdRegex.exec(req.url)
8888
89- if (req.url.startsWith('/user/')) return serveFeed(req, res, m[4])
90- else if (req.url.startsWith('/user-feed/')) return serveUserFeed(req, res, m[4])
89 + if (req.url.startsWith('/user-feed/')) return serveUserFeed(req, res, m[4])
9190 else if (req.url.startsWith('/channel/')) return serveChannel(req, res, m[4])
9291
92 + if (m[2] && m[2].length === 3) {
93 + m[1] = decodeURIComponent(m[1])
94 + m[2] = m[1][0]
95 + }
9396 switch (m[2]) {
94- case '%25': m[2] = '%'; m[1] = decodeURIComponent(m[1])
9597 case '%': return serveId(req, res, m[1], m[3], m[5])
98 + case '@': return serveFeed(req, res, m[1], m[3], m[5])
9699 case '&': return serveBlob(req, res, sbot, m[1])
97100 default: return servePath(req, res, m[4])
98101 }
99102 }
100103
101- function serveFeed(req, res, url) {
102- var feedId = url.substring(url.lastIndexOf('user/')+5, 100)
104 + function serveFeed(req, res, feedId) {
103105 console.log("serving feed: " + feedId)
104106
105107 var opts = defaultOpts
106108
@@ -555,9 +557,9 @@
555557 + '<img class="ssb-avatar-image" alt=""'
556558 + ' src="' + opts.img_base + escape(msg.author.image) + '"'
557559 + ' height="32" width="32">'
558560 + '<a class="ssb-avatar-name"'
559- + ' href="/user/' + escape(msg.value.author) + '"'
561 + + ' href="/' + escape(msg.value.author) + '"'
560562 + '>' + msg.author.name + '</a>'
561563 + msgTimestamp(msg, name)
562564 + render(opts, c)
563565 + '</div>'

Built with git-ssb-web