0

I want to implement a global whitelist functionality for safe URLs in bypassing resource URLs in Angular 2 similar to that provided by AngularJS through its $sceDelegateProvider as outlined here

I have tried referring to the Angular docs but I can't seem to find any help.

theJediCode
  • 112
  • 2
  • 12

1 Answers1

0

With angular you can use the sanitise function. Link to the document: https://angular.io/api/platform-browser/DomSanitizer#sanitize

let url = this.sanitiser.sanitise(SecurityContext.URL, urlVariable);

This will sanitise the url.

I would also suggest you to look at the owasp website for safe url's. They have regex which has worked for me in the apst. Link below: https://www.owasp.org/index.php/OWASP_Validation_Regex_Repository

ronakvp
  • 177
  • 3
  • 11