From 68b963638aa201a7bc10da1c8060b2900424af81 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 22 Jun 2020 09:04:33 +0200 Subject: [PATCH] MOBILE-3401 iframe: Don't call cookies plugin if no domain --- src/components/iframe/iframe.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/iframe/iframe.ts b/src/components/iframe/iframe.ts index 5806412bb..14dc98c54 100644 --- a/src/components/iframe/iframe.ts +++ b/src/components/iframe/iframe.ts @@ -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 = window; const urlParts = CoreUrl.parse(url); - await win.WKWebViewCookies.setCookie({ - name: 'MoodleAppCookieForWKWebView', - value: '1', - domain: urlParts.domain, - }); + 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);