Skip to content

Commit 68b9636

Browse files
committed
MOBILE-3401 iframe: Don't call cookies plugin if no domain
1 parent a1b557d commit 68b9636

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/components/iframe/iframe.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,19 @@ export class CoreIframeComponent implements OnChanges {
106106
if (changes.src) {
107107
const url = this.urlUtils.getYoutubeEmbedUrl(changes.src.currentValue) || changes.src.currentValue;
108108

109-
if (this.platform.is('ios') && !this.urlUtils.isLocalFileUrl(url)) {
109+
if (this.platform.is('ios') && url && !this.urlUtils.isLocalFileUrl(url)) {
110110
// Save a "fake" cookie for the iframe's domain to fix a bug in WKWebView.
111111
try {
112112
const win = <WKWebViewCookiesWindow> window;
113113
const urlParts = CoreUrl.parse(url);
114114

115-
await win.WKWebViewCookies.setCookie({
116-
name: 'MoodleAppCookieForWKWebView',
117-
value: '1',
118-
domain: urlParts.domain,
119-
});
115+
if (urlParts.domain) {
116+
await win.WKWebViewCookies.setCookie({
117+
name: 'MoodleAppCookieForWKWebView',
118+
value: '1',
119+
domain: urlParts.domain,
120+
});
121+
}
120122
} catch (err) {
121123
// Ignore errors.
122124
this.logger.error('Error setting cookie', err);

0 commit comments

Comments
 (0)