From c9381c6367dae06334fff19e30fabf772238eb93 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 22 Oct 2019 14:34:32 +0000 Subject: [PATCH] fix: addressed link detection issue (#2660) --- client/coral-admin/src/services/linkify.js | 8 -------- services/moderation/phases/links.js | 9 +++++++-- 2 files changed, 7 insertions(+), 10 deletions(-) delete mode 100644 client/coral-admin/src/services/linkify.js diff --git a/client/coral-admin/src/services/linkify.js b/client/coral-admin/src/services/linkify.js deleted file mode 100644 index c51d7261b..000000000 --- a/client/coral-admin/src/services/linkify.js +++ /dev/null @@ -1,8 +0,0 @@ -import LinkifyIt from 'linkify-it'; -import tlds from 'tlds'; - -export function createLinkify() { - const linkify = new LinkifyIt(); - linkify.tlds(tlds); - return linkify; -} diff --git a/services/moderation/phases/links.js b/services/moderation/phases/links.js index c31cf0c13..4cfbbc501 100644 --- a/services/moderation/phases/links.js +++ b/services/moderation/phases/links.js @@ -1,4 +1,4 @@ -const linkify = require('linkify-it')().tlds(require('tlds')); +const linkify = require('linkifyjs'); // This phase checks the comment if it has any links in it if the check is // enabled. @@ -11,7 +11,12 @@ module.exports = ( }, } ) => { - if (premodLinksEnable && linkify.test(comment.body.replace(/\xAD/g, ''))) { + if (premodLinksEnable) { + const links = linkify.find(comment.body.replace(/\xAD/g, '')); + if (!links || links.length === 0) { + return; + } + // Add the flag related to Trust to the comment. return { status: 'SYSTEM_WITHHELD',