|
|
@ -3,6 +3,8 @@ |
|
|
|
//
|
|
|
|
//
|
|
|
|
// Format JSON posts and DMs to HTML.
|
|
|
|
// Format JSON posts and DMs to HTML.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const _htmlFormatMsgAllowedUriSchemes = ['ed2k://', 'ipfs://', 'ipns://', 'magnet:?', 'xmmp:']; // TODO it should be optional
|
|
|
|
|
|
|
|
|
|
|
|
var _htmlFormatMsgLinkTemplateExternal; |
|
|
|
var _htmlFormatMsgLinkTemplateExternal; |
|
|
|
var _htmlFormatMsgLinkTemplateUser; |
|
|
|
var _htmlFormatMsgLinkTemplateUser; |
|
|
|
var _htmlFormatMsgLinkTemplateHashtag; |
|
|
|
var _htmlFormatMsgLinkTemplateHashtag; |
|
|
@ -720,16 +722,22 @@ function htmlFormatMsg(msg, opt) { |
|
|
|
msg = msgAddHtmlEntity(msg, i, i + str.length, |
|
|
|
msg = msgAddHtmlEntity(msg, i, i + str.length, |
|
|
|
newHtmlEntityLink(twister.tmpl.linkShortened, str, str)); |
|
|
|
newHtmlEntityLink(twister.tmpl.linkShortened, str, str)); |
|
|
|
i = msg.i; |
|
|
|
i = msg.i; |
|
|
|
} else if (['ipfs://', 'ipns://'].indexOf(msg.str.slice(i, i + 7).toLowerCase()) >= 0 |
|
|
|
} else { |
|
|
|
&& stopCharsRight.indexOf(msg.str[i + 7]) === -1) { |
|
|
|
for (k = 0; k < _htmlFormatMsgAllowedUriSchemes.length; k++) { |
|
|
|
j = getSubStrEnd(msg.str, i + 7, stopCharsRight, false, stopCharsTrailingUrl); |
|
|
|
let l = _htmlFormatMsgAllowedUriSchemes[k].length; |
|
|
|
if (j > i + 6) { |
|
|
|
if (_htmlFormatMsgAllowedUriSchemes[k] === msg.str.slice(i, i + l).toLowerCase() |
|
|
|
str = msg.str.slice(i, j + 1); |
|
|
|
&& stopCharsRight.indexOf(msg.str[i + l]) === -1) { |
|
|
|
msg = msgAddHtmlEntity(msg, i, i + str.length, |
|
|
|
j = getSubStrEnd(msg.str, i + l, stopCharsRight, false, stopCharsTrailingUrl); |
|
|
|
newHtmlEntityLink(_htmlFormatMsgLinkTemplateExternal, |
|
|
|
if (j > i + l - 1) { |
|
|
|
str, str) |
|
|
|
str = msg.str.slice(i, j + 1); |
|
|
|
); |
|
|
|
msg = msgAddHtmlEntity(msg, i, i + str.length, |
|
|
|
i = msg.i; |
|
|
|
newHtmlEntityLink(_htmlFormatMsgLinkTemplateExternal, |
|
|
|
|
|
|
|
str, str) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
i = msg.i; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|