better resilience on href, fix #276

This commit is contained in:
Nicolas Constant 2020-05-06 18:25:33 -04:00
parent 79566d4856
commit bdaa2068cf
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 12 additions and 1 deletions

View File

@ -31,6 +31,12 @@ describe('DatabindedTextComponent', () => {
expect(component.processedText).toContain(sample);
});
it('should parse href text', () => {
const sample = '<p>href<p>';
component.text = sample;
expect(component.processedText).toBe(sample);
});
it('should parse hashtag', () => {
const hashtag = 'programmers';
const url = 'https://test.social/tags/programmers';

View File

@ -28,7 +28,7 @@ export class DatabindedTextComponent implements OnInit {
@Input('text')
set text(value: string) {
//console.warn(value);
// console.warn(value);
let parser = new DOMParser();
var dom = parser.parseFromString(value, 'text/html')
@ -133,6 +133,11 @@ export class DatabindedTextComponent implements OnInit {
}
private processLink(section: string) {
if(!section.includes('</a>')){
this.processedText += section;
return;
}
let extractedLinkAndNext = section.split('</a>')
let extractedUrl = extractedLinkAndNext[0].split('"')[1];