Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unsupported URL issue on Ionic WKWebView #247

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/imgcache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down