To ensure that Angular allows specific URL protocols, you must modify its whitelist using a regular expression. By default, only http
, https
, ftp
, and mailto
are approved. When utilizing a protocol like chrome-extension:
that is not whitelisted, Angular will prepend the URL with unsafe:
.
An effective approach to include the chrome-extension:
protocol in the whitelist is within your module's configuration block:
var app = angular.module( 'myApp', [] )
.config( [
'$compileProvider',
function( $compileProvider )
{
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension):/);
// For Angular versions before v1.2, use $compileProvider.urlSanitizationWhitelist(...)
}
]);
This same method should be used when needing to utilize protocols like file:
and tel:
.
For further information, please refer to the AngularJS $compileProvider API documentation.