git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 418ac35b065b1ea7acf2d01ec7f1de61a5a721df

Files: 418ac35b065b1ea7acf2d01ec7f1de61a5a721df / router / sync / normalise.js

750 bytesRaw
1const nest = require('depnest')
2const { isBlob, isFeed, isMsg } = require('ssb-ref')
3
4exports.gives = nest('router.sync.normalise')
5
6exports.create = (api) => nest('router.sync.normalise', normalise)
7
8function normalise (location) {
9 if (typeof location === 'object') return location
10
11 if (isBlob(location)) return { blob: location }
12 if (isChannel(location)) return { channel: location }
13 if (isFeed(location)) return { feed: location }
14 if (isMsg(location)) return { key: location }
15 if (isPage(location)) return { page: location.substring(1) }
16}
17
18function isChannel (str) {
19 return typeof str === 'string' && str[0] === '#' && str.length > 1
20}
21
22function isPage (str) {
23 return typeof str === 'string' && str[0] === '/' && str.length > 1
24}
25

Built with git-ssb-web