be conditional and include quote with input board properly

merge-requests/208/head
fatchan 5 years ago
parent f05a8b0e68
commit 170badab6c
  1. 7
      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,13 +70,16 @@ module.exports = async (board, text) => {
}
//then replace the quotes with only ones that exist
if (quotes) {
text = text.replace(quoteRegex, (match) => {
const quotenum = +match.substring(2);
if (postThreadIdMap[quotenum]) {
if (postThreadIdMap[board] && postThreadIdMap[board][quotenum]) {
return `<a class='quote' href='/${board}/thread/${postThreadIdMap[board][quotenum]}#${quotenum}'>&gt;&gt;${quotenum}</a>`;
}
return match;
});
}
if (crossQuotes) {
text = text.replace(crossQuoteRegex, (match) => {
const quote = match.split('/');
const quoteboard = quote[1];
@ -87,6 +89,7 @@ module.exports = async (board, text) => {
}
return match;
});
}
return text;

Loading…
Cancel
Save