diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/render-msg.js | 2 | ||||
-rw-r--r-- | lib/util.js | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js index 76bcfad..250719d 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -99,7 +99,7 @@ RenderMsg.prototype.raw = function (cb) { // link to hashtags // TODO: recurse for (var k in c) { - if (!c[k] || c[k][0] !== '#') continue + if (!u.isChannel(c[k])) continue tok = u.token() tokens[tok] = h('a', {href: this.toUrl(c[k])}, c[k]) c[k] = tok diff --git a/lib/util.js b/lib/util.js index 519289a..2fa5c63 100644 --- a/lib/util.js +++ b/lib/util.js @@ -7,6 +7,7 @@ var u = exports u.ssbRefRegex = /((?:@|%|&|ssb:\/\/%)[A-Za-z0-9\/+]{43}=\.[\w\d]+)/g u.ssbRefRegexOnly = /^(?:@|%|&|ssb:\/\/%)[A-Za-z0-9\/+]{43}=\.[\w\d]+$/ u.ssbRefEncRegex = /((?:ssb:\/\/)?(?:[@%&]|%26|%40|%25)(?:[A-Za-z0-9\/+]|%2[fF]|%2[bB]){43}(?:=|%3[dD])\.[\w\d]+)/g +u.channelRegex = /^#[^\s#]+$/ u.isRef = function (str) { if (!str) return false @@ -14,6 +15,12 @@ u.isRef = function (str) { return u.ssbRefRegexOnly.test(str) } +u.isChannel = function (value) { + return typeof value === 'string' + && value.length < 30 + && u.channelRegex.test(value) +} + u.readNext = function (fn) { var next return function (end, cb) { |