import { Pipe, PipeTransform } from "@angular/core";
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";

@Pipe({
    name: 'sanitizeHtml',
    pure: false
})
export class SanitizerPipe implements PipeTransform {

    constructor(private _sanitizer: DomSanitizer) {
    }

    transform(v: string): SafeHtml {
        let html = this._sanitizer.bypassSecurityTrustHtml(v);
        if (html.hasOwnProperty("changingThisBreaksApplicationSecurity") && html["changingThisBreaksApplicationSecurity"].startsWith("<p>")) {
            html["changingThisBreaksApplicationSecurity"] = "<p>" + html["changingThisBreaksApplicationSecurity"].substr(html["changingThisBreaksApplicationSecurity"].indexOf('.') + 1);
        }
        return html;
    }
} 
import { Pipe, PipeTransform } from "@angular/core";
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";

@Pipe({
    name: 'sanitizeHtml',
    pure: false
})
export class SanitizerPipe implements PipeTransform {

    constructor(private _sanitizer: DomSanitizer) {
    }

    transform(v: string): SafeHtml {
        console.log("sanitize: " + v);
        let html = this._sanitizer.bypassSecurityTrustHtml(v);
        if (html.hasOwnProperty("changingThisBreaksApplicationSecurity") && /^<p>\d+\./.test(html["changingThisBreaksApplicationSecurity"])) {
            html["changingThisBreaksApplicationSecurity"] = "<p>" + html["changingThisBreaksApplicationSecurity"].substr(html["changingThisBreaksApplicationSecurity"].indexOf('.') + 1);
        }
        return html;
    }
} 
Fix broken links in details view
Fix broken links in details view

The matching for sanitizing elements in the reference list was too eager.
Instead of just checking if the HTML starts with "<p>" it now checks if
it starts with the REGEX "<p>\d+\.".
fixes #51

Signed-off-by: Armin Hueneburg <ce14971603cce67272d611a4f194786e96eb4828@gmail.com>
