Skip to content

Commit 18096c9

Browse files
committed
fix: Unsupported URL issue on Ionic WKWebView
1 parent dde6085 commit 18096c9

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/imgcache.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,21 @@ LOG_LEVEL_ERROR = 3;
175175
return (Helpers.isCordovaAndroid() && device.version && (device.version.indexOf('2.') === 0 || device.version.indexOf('3.') === 0));
176176
};
177177

178+
// special case for #223 #237 #246
179+
Helpers.ionicNormalizer = window.Ionic &&
180+
((window.Ionic.WebView && window.Ionic.WebView.convertFileSrc) || window.Ionic.normalizeURL);
181+
182+
Helpers.isIonicNormalizerFunctionExist = function() {
183+
return (typeof Helpers.ionicNormalizer === 'function');
184+
};
185+
178186
// Fix for #42 (Cordova versions < 4.0)
179187
Helpers.EntryToURL = function (entry) {
180188
if (Helpers.isCordovaAndroidOlderThan4() && typeof entry.toNativeURL === 'function') {
181189
return entry.toNativeURL();
182-
} else if (typeof entry.toInternalURL === 'function') {
190+
} else if (
191+
!Helpers.isIonicNormalizerFunctionExist() && // Fix for #223 #237 #246
192+
(typeof entry.toInternalURL === 'function')) {
183193
// Fix for #97
184194
return entry.toInternalURL();
185195
} else {
@@ -190,7 +200,9 @@ LOG_LEVEL_ERROR = 3;
190200
// Returns a URL that can be used to locate a file
191201
Helpers.EntryGetURL = function (entry) {
192202
// toURL for html5, toURI for cordova 1.x
193-
return (typeof entry.toURL === 'function' ? Helpers.EntryToURL(entry) : entry.toURI());
203+
var url = (typeof entry.toURL === 'function' ? Helpers.EntryToURL(entry) : entry.toURI());
204+
// Fix for #223 #237 #246
205+
return Helpers.isIonicNormalizerFunctionExist() ? Helpers.ionicNormalizer(url) : url;
194206
};
195207

196208
// Returns the full absolute path from the root to the FileEntry

0 commit comments

Comments
 (0)