fix new link pattern that wasn't supported
This commit is contained in:
parent
2697be3cb1
commit
17ad6faaef
|
@ -60,6 +60,13 @@ describe('DatabindedTextComponent', () => {
|
||||||
expect(component.processedText).toContain('bla2');
|
expect(component.processedText).toContain('bla2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse https://www. link', () => {
|
||||||
|
const url = 'bbc.com/news/magazine-34901704';
|
||||||
|
const sample = `<p>The rise of"<br><a href="https:www//${url}" rel="nofollow noopener" target="_blank"><span class="invisible">https://www.</span><span class="">${url}</span><span class="invisible"></span></a></p>`;
|
||||||
|
component.text = sample;
|
||||||
|
expect(component.processedText).toContain('<a href class="link-httpswwwbbccomnewsmagazine34901704" title="open link">bbc.com/news/magazine-34901704</a></p>');
|
||||||
|
});
|
||||||
|
|
||||||
it('should parse link - dual section', () => {
|
it('should parse link - dual section', () => {
|
||||||
const sample = `<p>Test.<br><a href="https://peertube.fr/videos/watch/69bb6e90-ec0f-49a3-9e28-41792f4a7c5f" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="ellipsis">peertube.fr/videos/watch/69bb6</span><span class="invisible">e90-ec0f-49a3-9e28-41792f4a7c5f</span></a></p>`;
|
const sample = `<p>Test.<br><a href="https://peertube.fr/videos/watch/69bb6e90-ec0f-49a3-9e28-41792f4a7c5f" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="ellipsis">peertube.fr/videos/watch/69bb6</span><span class="invisible">e90-ec0f-49a3-9e28-41792f4a7c5f</span></a></p>`;
|
||||||
|
|
||||||
|
@ -89,7 +96,7 @@ describe('DatabindedTextComponent', () => {
|
||||||
expect(component.processedText).toContain('bla2');
|
expect(component.processedText).toContain('bla2');
|
||||||
expect(component.processedText).toContain('bla3');
|
expect(component.processedText).toContain('bla3');
|
||||||
expect(component.processedText).toContain('bla4');
|
expect(component.processedText).toContain('bla4');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should parse link - GNU social in Mastodon', () => {
|
it('should parse link - GNU social in Mastodon', () => {
|
||||||
const sample = `bla1 <a href="https://www.lemonde.fr/planete.html?xtor=RSS-3208" rel="nofollow noopener" class="" target="_blank">https://social.bitcast.info/url/819438</a>`;
|
const sample = `bla1 <a href="https://www.lemonde.fr/planete.html?xtor=RSS-3208" rel="nofollow noopener" class="" target="_blank">https://social.bitcast.info/url/819438</a>`;
|
||||||
|
|
|
@ -22,6 +22,9 @@ export class DatabindedTextComponent implements OnInit {
|
||||||
|
|
||||||
@Input('text')
|
@Input('text')
|
||||||
set text(value: string) {
|
set text(value: string) {
|
||||||
|
// console.warn('text');
|
||||||
|
// console.warn(value);
|
||||||
|
|
||||||
this.processedText = '';
|
this.processedText = '';
|
||||||
let linksSections = value.split('<a ');
|
let linksSections = value.split('<a ');
|
||||||
|
|
||||||
|
@ -111,7 +114,7 @@ export class DatabindedTextComponent implements OnInit {
|
||||||
extractedName = extractedLinkAndNext[0].split('<span class="ellipsis">')[1].split('</span>')[0];
|
extractedName = extractedLinkAndNext[0].split('<span class="ellipsis">')[1].split('</span>')[0];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
try {
|
try {
|
||||||
extractedName = extractedLinkAndNext[0].split('<span class="invisible">https://</span><span class="">')[1].split('</span>')[0];
|
extractedName = extractedLinkAndNext[0].split(`<span class="">`)[1].split('</span>')[0];
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
extractedName = extractedLinkAndNext[0].split(' target="_blank">')[1].split('</span>')[0];
|
extractedName = extractedLinkAndNext[0].split(' target="_blank">')[1].split('</span>')[0];
|
||||||
|
|
Loading…
Reference in New Issue