From c64dabc6fc372b0fcb17d7153a1fed984b6a797e Mon Sep 17 00:00:00 2001 From: Jet Ma Date: Thu, 28 May 2020 16:32:03 +0800 Subject: [PATCH 1/4] fix: Unsupported URL issue on Ionic WKWebView --- lib/imgcache.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/imgcache.js b/lib/imgcache.js index 075829a..6f79162 100644 --- a/lib/imgcache.js +++ b/lib/imgcache.js @@ -175,11 +175,21 @@ LOG_LEVEL_ERROR = 3; return (Helpers.isCordovaAndroid() && device.version && (device.version.indexOf('2.') === 0 || device.version.indexOf('3.') === 0)); }; + // special case for #223 #237 #246 + Helpers.ionicNormalizer = window.Ionic && + ((window.Ionic.WebView && window.Ionic.WebView.convertFileSrc) || window.Ionic.normalizeURL); + + Helpers.isIonicNormalizerFunctionExist = function() { + return (typeof Helpers.ionicNormalizer === 'function'); + }; + // Fix for #42 (Cordova versions < 4.0) Helpers.EntryToURL = function (entry) { if (Helpers.isCordovaAndroidOlderThan4() && typeof entry.toNativeURL === 'function') { return entry.toNativeURL(); - } else if (typeof entry.toInternalURL === 'function') { + } else if ( + !Helpers.isIonicNormalizerFunctionExist() && // Fix for #223 #237 #246 + (typeof entry.toInternalURL === 'function')) { // Fix for #97 return entry.toInternalURL(); } else { @@ -190,7 +200,9 @@ LOG_LEVEL_ERROR = 3; // Returns a URL that can be used to locate a file Helpers.EntryGetURL = function (entry) { // toURL for html5, toURI for cordova 1.x - return (typeof entry.toURL === 'function' ? Helpers.EntryToURL(entry) : entry.toURI()); + var url = (typeof entry.toURL === 'function' ? Helpers.EntryToURL(entry) : entry.toURI()); + // Fix for #223 #237 #246 + return Helpers.isIonicNormalizerFunctionExist() ? Helpers.ionicNormalizer(url) : url; }; // Returns the full absolute path from the root to the FileEntry From dde6085034b2d7b7481779471f5de5f4002d02e5 Mon Sep 17 00:00:00 2001 From: Liam Mazy Date: Thu, 28 May 2020 17:20:28 +0800 Subject: [PATCH 2/4] Revert "fix: Unsupported URL issue on Ionic WKWebView" This reverts commit c64dabc6fc372b0fcb17d7153a1fed984b6a797e. --- lib/imgcache.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/lib/imgcache.js b/lib/imgcache.js index 6f79162..075829a 100644 --- a/lib/imgcache.js +++ b/lib/imgcache.js @@ -175,21 +175,11 @@ LOG_LEVEL_ERROR = 3; return (Helpers.isCordovaAndroid() && device.version && (device.version.indexOf('2.') === 0 || device.version.indexOf('3.') === 0)); }; - // special case for #223 #237 #246 - Helpers.ionicNormalizer = window.Ionic && - ((window.Ionic.WebView && window.Ionic.WebView.convertFileSrc) || window.Ionic.normalizeURL); - - Helpers.isIonicNormalizerFunctionExist = function() { - return (typeof Helpers.ionicNormalizer === 'function'); - }; - // Fix for #42 (Cordova versions < 4.0) Helpers.EntryToURL = function (entry) { if (Helpers.isCordovaAndroidOlderThan4() && typeof entry.toNativeURL === 'function') { return entry.toNativeURL(); - } else if ( - !Helpers.isIonicNormalizerFunctionExist() && // Fix for #223 #237 #246 - (typeof entry.toInternalURL === 'function')) { + } else if (typeof entry.toInternalURL === 'function') { // Fix for #97 return entry.toInternalURL(); } else { @@ -200,9 +190,7 @@ LOG_LEVEL_ERROR = 3; // Returns a URL that can be used to locate a file Helpers.EntryGetURL = function (entry) { // toURL for html5, toURI for cordova 1.x - var url = (typeof entry.toURL === 'function' ? Helpers.EntryToURL(entry) : entry.toURI()); - // Fix for #223 #237 #246 - return Helpers.isIonicNormalizerFunctionExist() ? Helpers.ionicNormalizer(url) : url; + return (typeof entry.toURL === 'function' ? Helpers.EntryToURL(entry) : entry.toURI()); }; // Returns the full absolute path from the root to the FileEntry From 18096c99df3b6878416284c70cf87a467bac8644 Mon Sep 17 00:00:00 2001 From: Liam Mazy Date: Thu, 28 May 2020 17:22:54 +0800 Subject: [PATCH 3/4] fix: Unsupported URL issue on Ionic WKWebView --- lib/imgcache.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/imgcache.js b/lib/imgcache.js index 075829a..6f79162 100644 --- a/lib/imgcache.js +++ b/lib/imgcache.js @@ -175,11 +175,21 @@ LOG_LEVEL_ERROR = 3; return (Helpers.isCordovaAndroid() && device.version && (device.version.indexOf('2.') === 0 || device.version.indexOf('3.') === 0)); }; + // special case for #223 #237 #246 + Helpers.ionicNormalizer = window.Ionic && + ((window.Ionic.WebView && window.Ionic.WebView.convertFileSrc) || window.Ionic.normalizeURL); + + Helpers.isIonicNormalizerFunctionExist = function() { + return (typeof Helpers.ionicNormalizer === 'function'); + }; + // Fix for #42 (Cordova versions < 4.0) Helpers.EntryToURL = function (entry) { if (Helpers.isCordovaAndroidOlderThan4() && typeof entry.toNativeURL === 'function') { return entry.toNativeURL(); - } else if (typeof entry.toInternalURL === 'function') { + } else if ( + !Helpers.isIonicNormalizerFunctionExist() && // Fix for #223 #237 #246 + (typeof entry.toInternalURL === 'function')) { // Fix for #97 return entry.toInternalURL(); } else { @@ -190,7 +200,9 @@ LOG_LEVEL_ERROR = 3; // Returns a URL that can be used to locate a file Helpers.EntryGetURL = function (entry) { // toURL for html5, toURI for cordova 1.x - return (typeof entry.toURL === 'function' ? Helpers.EntryToURL(entry) : entry.toURI()); + var url = (typeof entry.toURL === 'function' ? Helpers.EntryToURL(entry) : entry.toURI()); + // Fix for #223 #237 #246 + return Helpers.isIonicNormalizerFunctionExist() ? Helpers.ionicNormalizer(url) : url; }; // Returns the full absolute path from the root to the FileEntry From 6355aa7ca9203c434d055c60d7e925722f48d08e Mon Sep 17 00:00:00 2001 From: Liam Mazy Date: Thu, 28 May 2020 18:21:30 +0800 Subject: [PATCH 4/4] fix: Unsupported URL issue on Ionic WKWebView --- lib/imgcache.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/imgcache.js b/lib/imgcache.js index 6f79162..b2fa271 100644 --- a/lib/imgcache.js +++ b/lib/imgcache.js @@ -179,6 +179,7 @@ LOG_LEVEL_ERROR = 3; Helpers.ionicNormalizer = window.Ionic && ((window.Ionic.WebView && window.Ionic.WebView.convertFileSrc) || window.Ionic.normalizeURL); + // check if ionic webview convertfilesrc function exist Helpers.isIonicNormalizerFunctionExist = function() { return (typeof Helpers.ionicNormalizer === 'function'); };