git ssb

3+

dust / capsule



Commit 6787cc5778ab73694fedeb3f50bcce2da71f782f

improved URI parsing

dust committed on 4/9/2016, 6:58:17 PM
Parent: 578ffa8b1012f2827ca12664c52bd3cca2dd9757

Files changed

os/parserchanged
os/parserView
@@ -11,11 +11,15 @@
1111 payloadArray = parsedURI.query.split(/[\=\&]/)
1212
1313 // convert to key-val dict
1414 var payload = {}
15-for (var i = 0, len = payloadArray.length ; i<len ; i+=2) {
16- payload[payloadArray[i]] = (payloadArray[i+1])
17-}
15+var keysToParse = ['body', 'title', 'src', 'comment', 'channel', 'mentions']
16+keysToParse.forEach(function(key) {
17+ const keyPos = payloadArray.indexOf(key)
18+ if (keyPos !== -1) {
19+ payload[key] = payloadArray[keyPos + 1]
20+ }
21+})
1822
1923 // decode payload from base64
2024 payload.body = unescape(new Buffer(payload.body, 'base64').toString())
2125 if (typeof payload.comment === 'string') {
@@ -23,9 +27,9 @@
2327 }
2428 payload.title = unescape(payload.title)
2529 payload.channel = unescape(payload.channel)
2630
27-// ssbify the dang thing, finally
31+// ssbify the thing, finally
2832 var ssbifyString = require('ssbify-string')
2933 var ssbClient = require('ssb-client')
3034
3135 ssbClient(function (err, sbot) {

Built with git-ssb-web