From 35a3dedeb8b9670721bd363031083cc2c90fa085 Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 29 May 2017 06:38:49 -1000 Subject: Implement custom emoji rendering and uploading --- lib/util.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/util.js') 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 -- cgit v1.2.3