fix Pleroma 2.0.2 hashtag parsing
This commit is contained in:
parent
4b9cb381ce
commit
caf17f9662
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue