From fa093eca15053f21db531192a5d52c00348c8369 Mon Sep 17 00:00:00 2001 From: D4708 Date: Fri, 23 Apr 2021 02:45:59 +0300 Subject: [PATCH 1/2] add ipfs/ipns protocol links support --- js/twister_formatpost.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index 887ce6b..21dc5d6 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -720,6 +720,17 @@ function htmlFormatMsg(msg, opt) { msg = msgAddHtmlEntity(msg, i, i + str.length, newHtmlEntityLink(twister.tmpl.linkShortened, str, str)); i = msg.i; + } else if (['ipfs://', 'ipns://'].indexOf(msg.str.slice(i, i + 7).toLowerCase()) >= 0 && + stopCharsRight.indexOf(msg.str[i + 7]) === -1) { + j = getSubStrEnd(msg.str, i + 7, stopCharsRight, false, stopCharsTrailingUrl); + if (j > i + 6) { + str = msg.str.slice(i, j + 1); + msg = msgAddHtmlEntity(msg, i, i + str.length, + newHtmlEntityLink(_htmlFormatMsgLinkTemplateExternal, + str, str) + ); + i = msg.i; + } } } From 6c8ead1af5b9526c3a33cbcd913158808a35632c Mon Sep 17 00:00:00 2001 From: D4708 <76843085+D4708@users.noreply.github.com> Date: Tue, 27 Apr 2021 17:40:31 +0300 Subject: [PATCH 2/2] Update js/twister_formatpost.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Сёма Мрачный --- js/twister_formatpost.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index 21dc5d6..24d25dd 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -720,17 +720,17 @@ function htmlFormatMsg(msg, opt) { msg = msgAddHtmlEntity(msg, i, i + str.length, newHtmlEntityLink(twister.tmpl.linkShortened, str, str)); i = msg.i; - } else if (['ipfs://', 'ipns://'].indexOf(msg.str.slice(i, i + 7).toLowerCase()) >= 0 && - stopCharsRight.indexOf(msg.str[i + 7]) === -1) { - j = getSubStrEnd(msg.str, i + 7, stopCharsRight, false, stopCharsTrailingUrl); - if (j > i + 6) { - str = msg.str.slice(i, j + 1); - msg = msgAddHtmlEntity(msg, i, i + str.length, - newHtmlEntityLink(_htmlFormatMsgLinkTemplateExternal, - str, str) - ); - i = msg.i; - } + } else if (['ipfs://', 'ipns://'].indexOf(msg.str.slice(i, i + 7).toLowerCase()) >= 0 + && stopCharsRight.indexOf(msg.str[i + 7]) === -1) { + j = getSubStrEnd(msg.str, i + 7, stopCharsRight, false, stopCharsTrailingUrl); + if (j > i + 6) { + str = msg.str.slice(i, j + 1); + msg = msgAddHtmlEntity(msg, i, i + str.length, + newHtmlEntityLink(_htmlFormatMsgLinkTemplateExternal, + str, str) + ); + i = msg.i; + } } }