apply patches
This commit is contained in:
parent
f065fe98b2
commit
1bc05e87e4
2 changed files with 14 additions and 2 deletions
|
@ -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 <a {...{ attrs }} href={updatedLink}>
|
||||||
|
{ updatedChildren }
|
||||||
|
</a>
|
||||||
|
}
|
||||||
// Processor to use with html_tree_converter
|
// Processor to use with html_tree_converter
|
||||||
const processItem = (item, index, array, what) => {
|
const processItem = (item, index, array, what) => {
|
||||||
// Handle text nodes - just add emoji
|
// Handle text nodes - just add emoji
|
||||||
|
@ -171,6 +178,9 @@ export default Vue.component('RichContent', {
|
||||||
return renderMention(attrs, children)
|
return renderMention(attrs, children)
|
||||||
} else {
|
} else {
|
||||||
currentMentions = null
|
currentMentions = null
|
||||||
|
if (attrs['href']) {
|
||||||
|
return renderLink(attrs, children)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'span':
|
case 'span':
|
||||||
|
|
|
@ -36,11 +36,13 @@ describe('RichContent', () => {
|
||||||
it('unescapes everything as needed', () => {
|
it('unescapes everything as needed', () => {
|
||||||
const html = [
|
const html = [
|
||||||
p('Testing 'em all'),
|
p('Testing 'em all'),
|
||||||
'Testing 'em all'
|
'Testing 'em all',
|
||||||
|
'<a href="http://example.com?a=1&b=2">http://example.com?a=1&b=2</a>'
|
||||||
].join('')
|
].join('')
|
||||||
const expected = [
|
const expected = [
|
||||||
p('Testing \'em all'),
|
p('Testing \'em all'),
|
||||||
'Testing \'em all'
|
'Testing \'em all',
|
||||||
|
'<a href="http://example.com?a=1&b=2">http://example.com?a=1&b=2</a>'
|
||||||
].join('')
|
].join('')
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, {
|
||||||
localVue,
|
localVue,
|
||||||
|
|
Loading…
Reference in a new issue