MOBILE-3401 iframe: Don't call cookies plugin if no domain

main
Dani Palou 2020-06-22 09:04:33 +02:00
parent a1b557d926
commit 68b963638a
1 changed files with 8 additions and 6 deletions

View File

@ -106,17 +106,19 @@ export class CoreIframeComponent implements OnChanges {
if (changes.src) {
const url = this.urlUtils.getYoutubeEmbedUrl(changes.src.currentValue) || changes.src.currentValue;
if (this.platform.is('ios') && !this.urlUtils.isLocalFileUrl(url)) {
if (this.platform.is('ios') && url && !this.urlUtils.isLocalFileUrl(url)) {
// Save a "fake" cookie for the iframe's domain to fix a bug in WKWebView.
try {
const win = <WKWebViewCookiesWindow> window;
const urlParts = CoreUrl.parse(url);
if (urlParts.domain) {
await win.WKWebViewCookies.setCookie({
name: 'MoodleAppCookieForWKWebView',
value: '1',
domain: urlParts.domain,
});
}
} catch (err) {
// Ignore errors.
this.logger.error('Error setting cookie', err);