From 1bc05e87e4ca325b265c4d5b5ed01c1a8399637c Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Fri, 28 Jan 2022 19:07:28 +0000 Subject: [PATCH] apply patches --- src/components/rich_content/rich_content.jsx | 10 ++++++++++ test/unit/specs/components/rich_content.spec.js | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx index c0d20c5e..abe7db2f 100644 --- a/src/components/rich_content/rich_content.jsx +++ b/src/components/rich_content/rich_content.jsx @@ -108,6 +108,13 @@ export default Vue.component('RichContent', { } } + const renderLink = (attrs, children) => { + const updatedLink = attrs['href'].replace(/&/g, '&') + const updatedChildren = children.map(child => child.replace(attrs['href'], updatedLink)) + return + { updatedChildren } + + } // Processor to use with html_tree_converter const processItem = (item, index, array, what) => { // Handle text nodes - just add emoji @@ -171,6 +178,9 @@ export default Vue.component('RichContent', { return renderMention(attrs, children) } else { currentMentions = null + if (attrs['href']) { + return renderLink(attrs, children) + } break } case 'span': diff --git a/test/unit/specs/components/rich_content.spec.js b/test/unit/specs/components/rich_content.spec.js index f6c478a9..7251719a 100644 --- a/test/unit/specs/components/rich_content.spec.js +++ b/test/unit/specs/components/rich_content.spec.js @@ -36,11 +36,13 @@ describe('RichContent', () => { it('unescapes everything as needed', () => { const html = [ p('Testing 'em all'), - 'Testing 'em all' + 'Testing 'em all', + 'http://example.com?a=1&b=2' ].join('') const expected = [ p('Testing \'em all'), - 'Testing \'em all' + 'Testing \'em all', + 'http://example.com?a=1&b=2' ].join('') const wrapper = shallowMount(RichContent, { localVue,