fix Hometown hashtag, fix #357
This commit is contained in:
parent
1d9e3c5130
commit
030ce2e568
|
@ -47,6 +47,16 @@ describe('DatabindedTextComponent', () => {
|
||||||
expect(component.processedText).toContain('bla2');
|
expect(component.processedText).toContain('bla2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse hashtag - Hometown', () => {
|
||||||
|
const hashtag = 'MicroFiction';
|
||||||
|
const url = 'https://mastodon.social/tags/MicroFiction';
|
||||||
|
const sample = `<p>"bla1"<br><a href="${url}" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span class="article-type">${hashtag}</span></a> bla2</p>`;
|
||||||
|
component.text = sample;
|
||||||
|
expect(component.processedText).toContain(`<a href="${url}" class="hashtag-${hashtag}" title="#${hashtag}" target="_blank" rel="noopener noreferrer">#${hashtag}</a>`);
|
||||||
|
expect(component.processedText).toContain('bla1');
|
||||||
|
expect(component.processedText).toContain('bla2');
|
||||||
|
});
|
||||||
|
|
||||||
it('should parse hashtag - Pleroma 2.0.2', () => {
|
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`;
|
const sample = `Blabla <a class="hashtag" data-tag="covid19" href="https://url.com/tag/covid19">#covid19</a> Blibli`;
|
||||||
component.text = sample;
|
component.text = sample;
|
||||||
|
|
|
@ -93,7 +93,7 @@ export class DatabindedTextComponent implements OnInit {
|
||||||
|
|
||||||
private processHashtag(section: string) {
|
private processHashtag(section: string) {
|
||||||
let extractedLinkAndNext = section.split('</a>');
|
let extractedLinkAndNext = section.split('</a>');
|
||||||
let extractedHashtag = extractedLinkAndNext[0].split('#')[1].replace('<span>', '').replace('</span>', '');
|
let extractedHashtag = extractedLinkAndNext[0].split('#')[1].replace('<span class="article-type">', '').replace('<span>', '').replace('</span>', '');
|
||||||
let extractedUrl = extractedLinkAndNext[0].split('href="')[1].split('"')[0];
|
let extractedUrl = extractedLinkAndNext[0].split('href="')[1].split('"')[0];
|
||||||
|
|
||||||
let classname = this.getClassNameForHastag(extractedHashtag);
|
let classname = this.getClassNameForHastag(extractedHashtag);
|
||||||
|
|
Loading…
Reference in New Issue