fix Zap mention parsing

This commit is contained in:
Nicolas Constant 2020-08-28 22:42:00 -04:00
parent 534a4b11e3
commit 505f0b025a
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 11 additions and 0 deletions

View File

@ -163,6 +163,13 @@ describe('DatabindedTextComponent', () => {
expect(component.processedText).toContain('<a href class="account--test-mastodon-technology" title="@test@mastodon.technology">@test</a>');
});
it('should parse mention - Zap in Mastodon', () => {
const sample = `test @<span class="h-card"><a class="u-url mention" href="https://mastodon.social/@test" rel="nofollow noopener noreferrer" target="_blank">test</a></span> bla"`;
component.text = sample;
expect(component.processedText).toContain('test <span class="h-card"><a href class="account--test-mastodon-social" title="@test@mastodon.social">@test</a></span>');
});
it('should parse hastag - Pleroma', () => {
const sample = `<p>Bla <a href="https://ubuntu.social/tags/kubecon" rel="tag">#<span>KubeCon</span></a> Bla</p>`;

View File

@ -44,6 +44,10 @@ export class DatabindedTextComponent implements OnInit {
value = value.replace('class="mention" rel="nofollow noopener" target="_blank">@', 'class="mention" rel="nofollow noopener" target="_blank">'); //Misskey sanitarization
} while (value.includes('class="mention" rel="nofollow noopener" target="_blank">@'));
do {
value = value.replace('@<span class="h-card">', '<span class="h-card">'); //Zap sanitarization
} while (value.includes('@<span class="h-card">'));
let linksSections = value.split('<a ');
for (let section of linksSections) {