aboutsummaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-29 06:38:49 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-30 09:58:53 -1000
commit35a3dedeb8b9670721bd363031083cc2c90fa085 (patch)
tree96fca1e6767d22556f096ab8bb535aa2cfbe2265 /lib/util.js
parent9e859f9fe19da67e9688bd4310bd2bae75b3d5c1 (diff)
downloadpatchfoo-35a3dedeb8b9670721bd363031083cc2c90fa085.tar.gz
patchfoo-35a3dedeb8b9670721bd363031083cc2c90fa085.zip
Implement custom emoji rendering and uploading
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/util.js b/lib/util.js
index d25ecaf..f8da640 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -72,7 +72,7 @@ u.linkDest = function (link) {
}
u.toArray = function (x) {
- return !x ? [] : Array.isArray(x) ? x : [x]
+ return x == null ? [] : Array.isArray(x) ? x : [x]
}
u.fromArray = function (arr) {
@@ -102,7 +102,7 @@ u.tryDecodeJSON = function (json) {
}
}
-u.extractFeedIds = function (str) {
+u.extractRefs = function (str) {
var ids = []
String(str).replace(u.ssbRefRegex, function (id) {
ids.push(id)
@@ -110,6 +110,18 @@ u.extractFeedIds = function (str) {
return ids
}
+u.extractFeedIds = function (str) {
+ return u.extractRefs(str).filter(function (ref) {
+ return ref[0] === '@'
+ })
+}
+
+u.extractBlobIds = function (str) {
+ return u.extractRefs(str).filter(function (ref) {
+ return ref[0] === '&'
+ })
+}
+
u.isMsgReadable = function (msg) {
var c = msg && msg.value && msg.value.content
return typeof c === 'object' && c !== null