danday74 danday74 - 3 years ago 213
AngularJS Question

angular trusting a url - to escape or not to escape

this angular filter works great but do i include the line encodeURI or not?
i.e. does angular $sce.trustAsResourceUrl do it for you? the docs are silent.

.filter('trustUrl', trustUrl);

trustUrl.$inject = ['$sce'];

function trustUrl($sce) {
return function (url) {
url = encodeURI(url); // <<<< NEEDED ?
return $sce.trustAsResourceUrl(url);

Answer Source

I think I left it in in the end since it didn't seem to cause any harm

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download