fix Pleroma 2.0.2 hashtag parsing

This commit is contained in:
Nicolas Constant 2020-04-18 17:30:32 -04:00
parent 4b9cb381ce
commit caf17f9662
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 10 additions and 2 deletions

View File

@ -41,6 +41,14 @@ describe('DatabindedTextComponent', () => {
expect(component.processedText).toContain('bla2');
});
it('should parse hashtag - Pleroma 2.0.2', () => {
const sample = `Blabla <a class="hashtag" data-tag="covid19" href="https://url.com/tag/covid19">#covid19</a> Blibli`;
component.text = sample;
expect(component.processedText).toContain('<a href class="hashtag-covid19" title="#covid19">#covid19</a>');
expect(component.processedText).toContain('Blabla');
expect(component.processedText).toContain('Blibli');
});
it('should parse mention', () => {
const mention = 'sengi_app';
const url = 'https://mastodon.social/@sengi_app';

View File

@ -28,11 +28,11 @@ export class DatabindedTextComponent implements OnInit {
@Input('text')
set text(value: string) {
//console.warn(value);
let parser = new DOMParser();
var dom = parser.parseFromString(value, 'text/html')
this.isCollapsed = [...dom.body.textContent].length > 500;
//console.warn(this.isCollapsed);
this.processedText = '';
@ -52,7 +52,7 @@ export class DatabindedTextComponent implements OnInit {
continue;
}
if (section.includes('class="mention hashtag"') || section.includes('target="_blank">#') || section.includes('rel="tag">')) {
if (section.includes('class="mention hashtag"') || section.includes('class="hashtag"') || section.includes('target="_blank">#') || section.includes('rel="tag">')) {
try {
this.processHashtag(section);
}