Skip to content
New issue

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

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

Already on GitHub? # to your account

Remove unnecessary WKWebView/UIWebview logic #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 4 additions & 25 deletions src/ios/NativePageTransitions.m
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,6 @@ - (UIImage*) grabScreenshot {
}

- (BOOL) loadHrefIfPassed:(NSString*) href {
WKWebView *uiwebview = nil;
if ([self.webView isKindOfClass:[WKWebView class]]) {
uiwebview = ((WKWebView*)self.webView);
}
if (href != nil && ![href isEqual:[NSNull null]]) {
if (![href hasPrefix:@"#"]) {
// strip any params when looking for the file on the filesystem
Expand All @@ -735,11 +731,7 @@ - (BOOL) loadHrefIfPassed:(NSString*) href {
}
NSURL *url;
NSURL *origUrl;
if (self.wkWebView != nil) {
origUrl = self.wkWebView.URL;
} else {
origUrl = uiwebview.URL;
}
origUrl = self.wkWebView.URL;
if([origUrl.scheme isEqualToString:@"file"]) {
NSString *currentUrl = origUrl.absoluteString;
NSRange lastSlash = [currentUrl rangeOfString:@"/" options:NSBackwardsSearch];
Expand All @@ -761,24 +753,15 @@ - (BOOL) loadHrefIfPassed:(NSString*) href {

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];

// Utilize WKWebView for request if it exists
if (self.wkWebView != nil) {
[self.wkWebView loadRequest: urlRequest];
} else {
[uiwebview loadRequest: urlRequest];
}
[self.wkWebView loadRequest: urlRequest];
} else if (![href hasPrefix:@"#"]) {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"href must be null, a .html file or a #navigationhash"];
[self.commandDelegate sendPluginResult:pluginResult callbackId:_command.callbackId];
return NO;
} else {
// it's a hash, so load the url without any possible current hash
NSString *url = nil;
if (self.wkWebView != nil) {
url = self.wkWebView.URL.absoluteString;
} else {
url = uiwebview.URL.absoluteString;
}
url = self.wkWebView.URL.absoluteString;

// remove the # if it's still there
if ([url rangeOfString:@"#"].location != NSNotFound) {
Expand All @@ -790,11 +773,7 @@ - (BOOL) loadHrefIfPassed:(NSString*) href {
// and load it
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];

if (self.wkWebView != nil) {
[self.wkWebView loadRequest: urlRequest];
} else {
[uiwebview loadRequest: urlRequest];
}
[self.wkWebView loadRequest: urlRequest];
}
}
return YES;
Expand Down