2023-03-09 16:09:53 -05:00
|
|
|
// const regex = / \[\d+\..*?\]\(.*?\)/g;
|
|
|
|
|
const regex = / \[.*?]\(.*?\)/g;
|
|
|
|
|
|
|
|
|
|
const getCitations = (res) => {
|
2023-05-11 09:23:15 +08:00
|
|
|
const adaptiveCards = res.details.adaptiveCards;
|
|
|
|
|
const textBlocks = adaptiveCards && adaptiveCards[0].body;
|
2023-03-09 16:09:53 -05:00
|
|
|
if (!textBlocks) return '';
|
|
|
|
|
let links = textBlocks[textBlocks.length - 1]?.text.match(regex);
|
2023-03-09 18:07:36 -05:00
|
|
|
if (links?.length === 0 || !links) return '';
|
2023-05-18 11:44:07 -07:00
|
|
|
links = links.map((link) => link.trim());
|
2023-03-09 18:42:36 -05:00
|
|
|
return links.join('\n');
|
2023-03-09 16:09:53 -05:00
|
|
|
};
|
|
|
|
|
|
2023-05-18 11:09:31 -07:00
|
|
|
module.exports = getCitations;
|