MOBILE-3401 iframe: Don't call cookies plugin if no domain
parent
a1b557d926
commit
68b963638a
|
@ -106,17 +106,19 @@ export class CoreIframeComponent implements OnChanges {
|
||||||
if (changes.src) {
|
if (changes.src) {
|
||||||
const url = this.urlUtils.getYoutubeEmbedUrl(changes.src.currentValue) || changes.src.currentValue;
|
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.
|
// Save a "fake" cookie for the iframe's domain to fix a bug in WKWebView.
|
||||||
try {
|
try {
|
||||||
const win = <WKWebViewCookiesWindow> window;
|
const win = <WKWebViewCookiesWindow> window;
|
||||||
const urlParts = CoreUrl.parse(url);
|
const urlParts = CoreUrl.parse(url);
|
||||||
|
|
||||||
|
if (urlParts.domain) {
|
||||||
await win.WKWebViewCookies.setCookie({
|
await win.WKWebViewCookies.setCookie({
|
||||||
name: 'MoodleAppCookieForWKWebView',
|
name: 'MoodleAppCookieForWKWebView',
|
||||||
value: '1',
|
value: '1',
|
||||||
domain: urlParts.domain,
|
domain: urlParts.domain,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
this.logger.error('Error setting cookie', err);
|
this.logger.error('Error setting cookie', err);
|
||||||
|
|
Loading…
Reference in New Issue