Getting unsafe url error after updating to RC2

My ionic 2 app was working fine under Beta 11 but since updating the app to RC2 I get “unsafe value used in a resource URL context” for <img [src]="myURL">. The myURL values refer to images in an AWS S3 bucket.

I have tried using a DomSanitizer as follows but still get the error.

import { Nav, Loading, ToastController, MenuController, AlertController, ActionSheetController, Platform, LoadingController } from 'ionic-angular';
import { Storage } from "@ionic/storage";
import { Inject, Component, NgZone } from '@angular/core';
import { MediaItemData } from '../../providers/item-data';
import { DomSanitizer } from '@angular/platform-browser';

@Component({
templateUrl: 'veeu.html'
})
export class VeeUPage {
mediaItems: any = [];
theMediaItem: any = [];

constructor(public sanitizer: DomSanitizer, public mediaItemData: MediaItemData) {
    this.getMediaItemData();
}

getMediaItemData() {
    this.mediaItemData.loadMediaItems(1, 60, 'ALL').then((mediaItems: any) => {

        this.mediaItems = mediaItems.results;
        this.mediaItems.forEach(function (item) {
            alert('before: ' + item.url);
            item.url = this.sanitizer.bypassSecurityTrustUrl(item.url);
            alert('after');
        });
    });
}
}

bypassSecurityTrustUrl and bypassSecurityTrustResourceUrl are different beasts.

1 Like

Yes indeed. Are you suggesting I should be using trust resource? I have tried both.