better resilience on href, fix #276
This commit is contained in:
parent
79566d4856
commit
bdaa2068cf
@ -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';
|
||||
|
@ -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];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user