diff --git a/package-lock.json b/package-lock.json index f4ffdac72ef1..0860535f265b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,7 +41,7 @@ "babel-polyfill": "^6.26.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#77b3790c00be80ec2d3ac3db59c24b9e3ad68eb0", + "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#68abe48ad71a98604fdbf5e8e960023ed5807ec2", "fbjs": "^3.0.2", "html-entities": "^1.3.1", "htmlparser2": "^7.2.0", @@ -23520,8 +23520,8 @@ }, "node_modules/expensify-common": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#77b3790c00be80ec2d3ac3db59c24b9e3ad68eb0", - "integrity": "sha512-aQs6seGToCIxX5LhPH5wUwM4mLWuyp1LkykmJf1gqdHpSJZV1S/oEg/0N0JamF+in6mwxf/mldfIqEqXXIvK/A==", + "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#68abe48ad71a98604fdbf5e8e960023ed5807ec2", + "integrity": "sha512-OhM2d7W++k0RVscwBpl0cvKXp3aZmflVawQ9Ebh2RBTdy98VZUwq2iZyCDISGNyETthqqsRq8vxy2lFQZZ19RA==", "license": "MIT", "dependencies": { "classnames": "2.3.1", @@ -57401,9 +57401,9 @@ } }, "expensify-common": { - "version": "git+ssh://git@github.com/Expensify/expensify-common.git#77b3790c00be80ec2d3ac3db59c24b9e3ad68eb0", - "integrity": "sha512-aQs6seGToCIxX5LhPH5wUwM4mLWuyp1LkykmJf1gqdHpSJZV1S/oEg/0N0JamF+in6mwxf/mldfIqEqXXIvK/A==", - "from": "expensify-common@git+ssh://git@github.com/Expensify/expensify-common.git#77b3790c00be80ec2d3ac3db59c24b9e3ad68eb0", + "version": "git+ssh://git@github.com/Expensify/expensify-common.git#68abe48ad71a98604fdbf5e8e960023ed5807ec2", + "integrity": "sha512-OhM2d7W++k0RVscwBpl0cvKXp3aZmflVawQ9Ebh2RBTdy98VZUwq2iZyCDISGNyETthqqsRq8vxy2lFQZZ19RA==", + "from": "expensify-common@git+ssh://git@github.com/Expensify/expensify-common.git#68abe48ad71a98604fdbf5e8e960023ed5807ec2", "requires": { "classnames": "2.3.1", "clipboard": "2.0.4", diff --git a/package.json b/package.json index d9439c609a9e..1fefae74c945 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "babel-polyfill": "^6.26.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#77b3790c00be80ec2d3ac3db59c24b9e3ad68eb0", + "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#68abe48ad71a98604fdbf5e8e960023ed5807ec2", "fbjs": "^3.0.2", "html-entities": "^1.3.1", "htmlparser2": "^7.2.0", diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 42e3b3cfc1f4..fa3792cbe167 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -897,32 +897,6 @@ function deleteReportComment(reportID, reportAction) { API.write('DeleteComment', parameters, {optimisticData, successData, failureData}); } -/** - * @param {String} comment - * @returns {Array} - */ -const extractLinksInMarkdownComment = (comment) => { - const regex = /\[[^[\]]*\]\(([^()]*)\)/gm; - const matches = [...comment.matchAll(regex)]; - - // Element 1 from match is the regex group if it exists which contains the link URLs - const links = _.map(matches, (match) => Str.sanitizeURL(match[1])); - return links; -}; - -/** - * Compares two markdown comments and returns a list of the links removed in a new comment. - * - * @param {String} oldComment - * @param {String} newComment - * @returns {Array} - */ -const getRemovedMarkdownLinks = (oldComment, newComment) => { - const linksInOld = extractLinksInMarkdownComment(oldComment); - const linksInNew = extractLinksInMarkdownComment(newComment); - return _.difference(linksInOld, linksInNew); -}; - /** * Removes the links in html of a comment. * example: @@ -958,7 +932,7 @@ const handleUserDeletedLinksInHtml = (newCommentText, originalHtml) => { } const markdownOriginalComment = parser.htmlToMarkdown(originalHtml).trim(); const htmlForNewComment = parser.replace(newCommentText); - const removedLinks = getRemovedMarkdownLinks(markdownOriginalComment, newCommentText); + const removedLinks = parser.getRemovedMarkdownLinks(markdownOriginalComment, newCommentText); return removeLinksFromHtml(htmlForNewComment, removedLinks); };