From 6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Wed, 29 Aug 2018 17:01:32 +0300 Subject: merge from ecomp a88f0072 - Modern UI Issue-ID: VID-378 Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6 Signed-off-by: Ittay Stern --- .../src/app/shared/pipes/safe/safe.pipe.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.ts (limited to 'vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.ts') diff --git a/vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.ts b/vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.ts new file mode 100644 index 000000000..cff5b61a9 --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.ts @@ -0,0 +1,22 @@ +// @ts-ignore +import {DomSanitizer, SafeHtml, SafeResourceUrl, SafeScript, SafeStyle, SafeUrl} from "@angular/platform-browser"; +import {Pipe, PipeTransform} from "@angular/core"; + + +@Pipe({ + name: 'safe' +}) +export class SafePipe implements PipeTransform { + + constructor(protected sanitizer: DomSanitizer) {} + + public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl { + switch (type) { + case 'html': return this.sanitizer.bypassSecurityTrustHtml(value); + case 'style': return this.sanitizer.bypassSecurityTrustStyle(value); + case 'script': return this.sanitizer.bypassSecurityTrustScript(value); + case 'url': return this.sanitizer.bypassSecurityTrustUrl(value); + case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value); + } + } +} -- cgit 1.2.3-korg