better mention detection in pleroma via mastodon

This commit is contained in:
Nicolas Constant 2018-11-01 21:00:41 -04:00
parent 6494ce5907
commit a22b16c74e
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 4 additions and 6 deletions

View File

@ -99,7 +99,7 @@ describe('DatabindedTextComponent', () => {
expect(component.processedText).toContain('bla1');
});
it('should parse mention - GNU social in Mastodon', () => {
it('should parse mention - Pleroma in Mastodon', () => {
const sample = `<div>bla1 <br> @<a href="https://instance.club/user/1" class="h-card mention status-link" rel="noopener" target="_blank" title="https://instance.club/user/1">user</a>&nbsp;</div>`;
component.text = sample;
@ -107,12 +107,10 @@ describe('DatabindedTextComponent', () => {
expect(component.processedText).toContain('bla1');
})
it('should parse mention - Pleroma in Mastodon', () => {
it('should parse mention - Pleroma in Mastodon - 2', () => {
const sample = `<div><span><a class="mention status-link" href="https://pleroma.site/users/kaniini" rel="noopener" target="_blank" title="kaniini@pleroma.site">@<span>kaniini</span></a></span> <span><a class="mention status-link" href="https://mastodon.social/@Gargron" rel="noopener" target="_blank" title="Gargron@mastodon.social">@<span>Gargron</span></a></span> bla1?</div>`;
component.text = sample;
expect(component.processedText).toContain('<div><span><a href class="account--kaniini-pleroma-site" title="@kaniini@pleroma.site">@kaniini</a> <span><a href class="account--Gargron-mastodon-social" title="@Gargron@mastodon.social">@Gargron</a> bla1?</div>');
});
});
});

View File

@ -40,7 +40,7 @@ export class DatabindedTextComponent implements OnInit {
console.warn(value);
}
} else if (section.includes('class="u-url mention"') || section.includes('class="mention"') || section.includes('class="mention status-link"') || section.includes('class="h-card mention status-link"')) {
} else if (section.includes('class="u-url mention"') || section.includes('class="mention"') || section.includes('class="mention status-link"') || section.includes('class="h-card mention')) {
try {
this.processUser(section);
}