Commit 4b8b575056eccf0674ea21d953dcb8e779930049
normalise URIencoded message links so you are redirected to an acutal message
mix irving committed on 3/1/2018, 10:19:06 PMParent: dc2e96d4d0a86072d9393a2d15d786a80cb341ff
Files changed
router/async/normalise.js | changed |
router/async/normalise.js | |||
---|---|---|---|
@@ -11,10 +11,19 @@ | |||
11 | 11 … | exports.create = (api) => { | |
12 | 12 … | return nest('router.async.normalise', normalise) | |
13 | 13 … | ||
14 | 14 … | function normalise (location, cb) { | |
15 | - if (typeof location === 'object') cb(null, location) | ||
16 | - else if (isMsg(location)) { | ||
15 … | + if (typeof location === 'object') { | ||
16 … | + cb(null, location) | ||
17 … | + return true | ||
18 … | + } | ||
19 … | + | ||
20 … | + // if someone has given you an annoying html encoded location | ||
21 … | + if (location.match(/^%25.*%3D.sha256$/)) { | ||
22 … | + location = decodeURIComponent(location) | ||
23 … | + } | ||
24 … | + | ||
25 … | + if (isMsg(location)) { | ||
17 | 26 … | api.sbot.async.get(location, (err, value) => { | |
18 | 27 … | if (err) cb(err) | |
19 | 28 … | else { | |
20 | 29 … | if (typeof value.content === 'string') value = api.message.sync.unbox(value) |
Built with git-ssb-web