added new Friendica mention parsing rule
This commit is contained in:
parent
86ce3e5ae0
commit
0e9bff10f6
|
@ -120,4 +120,11 @@ describe('DatabindedTextComponent', () => {
|
|||
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>');
|
||||
});
|
||||
|
||||
it('should parse mention - Friendica in Mastodon', () => {
|
||||
const sample = `@<span class=""><a href="https://m.s/me" class="u-url mention" rel="nofollow noopener" target="_blank"><span class="mention">me</span></a></span> Blablabla.`;
|
||||
|
||||
component.text = sample;
|
||||
expect(component.processedText).toContain('<span class=""><a href class="account--me-m-s" title="@me@m.s">@me</a></span> Blablabla.');
|
||||
});
|
||||
});
|
|
@ -22,10 +22,13 @@ export class DatabindedTextComponent implements OnInit {
|
|||
|
||||
@Input('text')
|
||||
set text(value: string) {
|
||||
// console.warn('text');
|
||||
// console.warn(value);
|
||||
console.warn('text');
|
||||
console.warn(value);
|
||||
|
||||
this.processedText = '';
|
||||
|
||||
value = value.replace('@<span class="">', '<span class="">'); //Friendica sanitarization
|
||||
|
||||
let linksSections = value.split('<a ');
|
||||
|
||||
for (let section of linksSections) {
|
||||
|
@ -77,7 +80,10 @@ export class DatabindedTextComponent implements OnInit {
|
|||
let extractedAccountAndNext: string[];
|
||||
let extractedAccountName: string;
|
||||
|
||||
if (!section.includes('@<span>')) { //GNU social
|
||||
if(section.includes('<span class="mention">')){ //Friendica
|
||||
extractedAccountAndNext = section.split('</a>');
|
||||
extractedAccountName = extractedAccountAndNext[0].split('<span class="mention">')[1].split('</span>')[0];
|
||||
} else if (!section.includes('@<span>')) { //GNU social
|
||||
extractedAccountAndNext = section.split('</a>');
|
||||
extractedAccountName = extractedAccountAndNext[0].split('>')[1];
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue