generated from PackagrIO/goweb-template
-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make sure we can display alias values in search
fixes #299
- Loading branch information
Showing
6 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { SafeHtmlPipe } from './safe-html.pipe'; | ||
import {DomSanitizer} from '@angular/platform-browser'; | ||
|
||
// describe('SafeHtmlPipe', () => { | ||
// it('create an instance', () => { | ||
// const pipe = new SafeHtmlPipe(new DomSanitizer()); | ||
// expect(pipe).toBeTruthy(); | ||
// }); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import {DomSanitizer, SafeHtml, SafeResourceUrl, SafeScript, SafeStyle, SafeUrl} from '@angular/platform-browser'; | ||
|
||
@Pipe({ | ||
name: 'safeHtml' | ||
}) | ||
export class SafeHtmlPipe implements PipeTransform { | ||
constructor(private sanitized: DomSanitizer) {} | ||
|
||
transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl { | ||
switch (type) { | ||
case 'html': return this.sanitized.bypassSecurityTrustHtml(value); | ||
case 'style': return this.sanitized.bypassSecurityTrustStyle(value); | ||
case 'script': return this.sanitized.bypassSecurityTrustScript(value); | ||
case 'url': return this.sanitized.bypassSecurityTrustUrl(value); | ||
case 'resourceUrl': return this.sanitized.bypassSecurityTrustResourceUrl(value); | ||
default: throw new Error(`Invalid safe type specified: ${type}`); | ||
} | ||
} | ||
|
||
} |