git ssb

16+

Dominic / patchbay



Commit a90a1c43ce789756570fb5b3b4601ddd6614b091

Merge pull request #306 from ssbc/support-ssb-uri

Add SSB URI support
mix irving authored on 1/30/2019, 12:48:46 AM
GitHub committed on 1/30/2019, 12:48:46 AM
Parent: d006827557e63f5aabd07e480b910ca50ddb9646
Parent: 9685f2bac5b5ddf1f41373900ab3405b765c7076

Files changed

app/async/catch-link-click.jschanged
app/html/search-bar.jschanged
package-lock.jsonchanged
package.jsonchanged
router/async/normalise.jschanged
app/async/catch-link-click.jsView
@@ -1,6 +1,5 @@
@@ -31,9 +30,17 @@
app/html/search-bar.jsView
@@ -17,11 +17,13 @@
1717 return nest('app.html.searchBar', function searchBar () {
1818 if (_search) return _search
1919
2020 function goToLocation (location, ev) {
21 + const prefixes = ['@', '#', '%', '&', '/', 'ssb:']
22 +
2123 if (location[0] === '?') {
2224 location = { page: 'search', query: location.substring(1) }
23- } else if (!['@', '#', '%', '&', '/'].includes(location[0])) {
25 + } else if (prefixes.every(p => !location.startsWith(p))) {
2426 location = { page: 'search', query: location }
2527 }
2628
2729 api.app.sync.goTo(location)
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 587807 bytes
New file size: 589463 bytes
package.jsonView
@@ -111,8 +111,9 @@
111111 "ssb-server": "^14.0.3",
112112 "ssb-sort": "^1.1.0",
113113 "ssb-suggest": "^1.0.3",
114114 "ssb-unread": "^1.0.2",
115 + "ssb-uri": "^1.0.1",
115116 "ssb-ws": "^4.0.1",
116117 "suggest-box": "^2.2.3",
117118 "text-node-searcher": "^1.1.1",
118119 "xtend": "^4.0.1"
router/async/normalise.jsView
@@ -1,6 +1,7 @@
11 const nest = require('depnest')
22 const { isBlobLink, isFeed, isMsg } = require('ssb-ref')
3 +const ssbUri = require('ssb-uri')
34
45 exports.gives = nest('router.async.normalise')
56
67 exports.needs = nest({
@@ -21,8 +22,16 @@
2122 if (location.match(/^%25.*%3D.sha256$/)) {
2223 location = decodeURIComponent(location)
2324 }
2425
26 + if (location.startsWith('ssb:')) {
27 + try {
28 + location = ssbUri.toSigilLink(location)
29 + } catch (err) {
30 + cb(err)
31 + }
32 + }
33 +
2534 if (isMsg(location)) {
2635 api.sbot.async.get(location, (err, value) => {
2736 if (err) cb(err)
2837 else {

Built with git-ssb-web