Co-authored-by: bastien ollier <bastien.ollier@etu.uca.fr> Reviewed-on: #6 Reviewed-by: Clément FRÉVILLE <clement.freville2@etu.uca.fr> Co-authored-by: Bastien OLLIER <bastien.ollier@noreply.codefirst.iut.uca.fr> Co-committed-by: Bastien OLLIER <bastien.ollier@noreply.codefirst.iut.uca.fr>pull/7/head
parent
cf74413fc7
commit
d41629abd0
@ -0,0 +1,8 @@
|
||||
import { SafeHTMLPipe } from './safe-html.pipe';
|
||||
|
||||
describe('SafeHTMLPipe', () => {
|
||||
it('create an instance', () => {
|
||||
const pipe = new SafeHTMLPipe();
|
||||
expect(pipe).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,15 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
|
||||
@Pipe({
|
||||
name: 'safeHTML',
|
||||
})
|
||||
export class SafeHTMLPipe implements PipeTransform {
|
||||
|
||||
constructor(protected sanitizer: DomSanitizer) {}
|
||||
|
||||
transform(value: unknown, ...args: unknown[]): unknown {
|
||||
return this.sanitizer.bypassSecurityTrustHtml(value as string);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue