How to use the ssb-ref.parseLink function in ssb-ref

To help you get started, we’ve selected a few ssb-ref examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github soapdog / patchfox / src / patchpatchcore / message / html / markdown.js View on Github external
toUrl: (id) => {
                    var link = ref.parseLink(id);
                    if (link && ref.isBlob(link.link)) {
                        var url = api.blob.sync.url(link.link);
                        var query = {};
                        if (link.query && link.query.unbox)
                            query["unbox"] = link.query.unbox;
                        if (typeLookup[link.link])
                            query["contentType"] = typeLookup[link.link];
                        return url + "?" + querystring.stringify(query);
                    }
                    else if (link || id.startsWith("#") || id.startsWith("?")) {
                        return id;
                    }
                    else if (mentions[id]) {
                        // handle old-style patchwork v2 mentions (deprecated)
                        return mentions[id];
                    }
github ssbc / ssb-db / create.js View on Github external
if (isPrivate && unbox) {
          data = db.unbox(data, unbox)
        }

        let result

        if (isPrivate) {
          result = data.value
        } else {
          result = u.originalValue(data.value)
        }

        cb(null, !meta ? result : {key: data.key, value: result, timestamp: data.timestamp})
      })
    } else if (ref.isMsgLink(key)) {
      var link = ref.parseLink(key)
      return db.get({
        id: link.link,
        private: true,
        unbox: link.query.unbox.replace(/\s/g, '+'),
        meta: link.query.meta
      }, cb)
    } else if (Number.isInteger(key)) {
      _get(key, cb) // seq
    } else {
      throw new Error('ssb-db.get: key *must* be a ssb message id or a flume offset')
    }
  }