diff --git a/helpers/quotes.js b/helpers/quotes.js index 5a117980..830884a9 100644 --- a/helpers/quotes.js +++ b/helpers/quotes.js @@ -54,7 +54,6 @@ module.exports = async (board, text) => { //get all the posts from quotes const posts = await Posts.getPostsForQuotes(queryOrs); - //if none of the quotes were real, dont do a replace if (posts.length === 0) { return text; @@ -71,22 +70,26 @@ module.exports = async (board, text) => { } //then replace the quotes with only ones that exist - text = text.replace(quoteRegex, (match) => { - const quotenum = +match.substring(2); - if (postThreadIdMap[quotenum]) { - return `>>${quotenum}`; - } - return match; - }); - text = text.replace(crossQuoteRegex, (match) => { - const quote = match.split('/'); - const quoteboard = quote[1]; - const quotenum = +quote[2]; - if (postThreadIdMap[quoteboard] && postThreadIdMap[quoteboard][quotenum]) { - return `>>>/${quoteboard}/${quotenum}`; - } - return match; - }); + if (quotes) { + text = text.replace(quoteRegex, (match) => { + const quotenum = +match.substring(2); + if (postThreadIdMap[board] && postThreadIdMap[board][quotenum]) { + return `>>${quotenum}`; + } + return match; + }); + } + if (crossQuotes) { + text = text.replace(crossQuoteRegex, (match) => { + const quote = match.split('/'); + const quoteboard = quote[1]; + const quotenum = +quote[2]; + if (postThreadIdMap[quoteboard] && postThreadIdMap[quoteboard][quotenum]) { + return `>>>/${quoteboard}/${quotenum}`; + } + return match; + }); + } return text;