Commit a606674d3015f7f239614695ba937bc8d8bf6226
merge with @cel
Anders Rune Jensen committed on 4/17/2017, 6:44:33 AMParent: 5c13d7dc8dd9c1117f5e31633ddb3e5858ee474c
Parent: 7b1296a17c686246a78705ff9f4d90b54c294c86
Files changed
index.js | changed |
index.js | |||
---|---|---|---|
@@ -17,9 +17,9 @@ | |||
17 | 17 … | ||
18 | 18 … | var emojiDir = path.join(require.resolve('emoji-named-characters'), '../pngs') | |
19 | 19 … | var appHash = hash([fs.readFileSync(__filename)]) | |
20 | 20 … | ||
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))(?:\.([^?]*))?|(\/.*?))(?:\?(.*))?$/ | ||
22 | 22 … | ||
23 | 23 … | function MdRenderer(opts) { | |
24 | 24 … | marked.Renderer.call(this, {}) | |
25 | 25 … | this.opts = opts | |
@@ -85,22 +85,24 @@ | |||
85 | 85 … | } | |
86 | 86 … | ||
87 | 87 … | var m = urlIdRegex.exec(req.url) | |
88 | 88 … | ||
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]) | ||
91 | 90 … | else if (req.url.startsWith('/channel/')) return serveChannel(req, res, m[4]) | |
92 | 91 … | ||
92 … | + if (m[2] && m[2].length === 3) { | ||
93 … | + m[1] = decodeURIComponent(m[1]) | ||
94 … | + m[2] = m[1][0] | ||
95 … | + } | ||
93 | 96 … | switch (m[2]) { | |
94 | - case '%25': m[2] = '%'; m[1] = decodeURIComponent(m[1]) | ||
95 | 97 … | case '%': return serveId(req, res, m[1], m[3], m[5]) | |
98 … | + case '@': return serveFeed(req, res, m[1], m[3], m[5]) | ||
96 | 99 … | case '&': return serveBlob(req, res, sbot, m[1]) | |
97 | 100 … | default: return servePath(req, res, m[4]) | |
98 | 101 … | } | |
99 | 102 … | } | |
100 | 103 … | ||
101 | - function serveFeed(req, res, url) { | ||
102 | - var feedId = url.substring(url.lastIndexOf('user/')+5, 100) | ||
104 … | + function serveFeed(req, res, feedId) { | ||
103 | 105 … | console.log("serving feed: " + feedId) | |
104 | 106 … | ||
105 | 107 … | var opts = defaultOpts | |
106 | 108 … | ||
@@ -555,9 +557,9 @@ | |||
555 | 557 … | + '<img class="ssb-avatar-image" alt=""' | |
556 | 558 … | + ' src="' + opts.img_base + escape(msg.author.image) + '"' | |
557 | 559 … | + ' height="32" width="32">' | |
558 | 560 … | + '<a class="ssb-avatar-name"' | |
559 | - + ' href="/user/' + escape(msg.value.author) + '"' | ||
561 … | + + ' href="/' + escape(msg.value.author) + '"' | ||
560 | 562 … | + '>' + msg.author.name + '</a>' | |
561 | 563 … | + msgTimestamp(msg, name) | |
562 | 564 … | + render(opts, c) | |
563 | 565 … | + '</div>' |
Built with git-ssb-web