Skip to content

Commit

Permalink
fix: re-add handling invalid appUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed Mar 2, 2020
1 parent 1e62b8f commit 4eb3e07
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions CordovaLib/Classes/Public/CDVViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,27 @@ - (void)viewDidLoad
[CDVTimer stop:@"TotalPluginStartup"];
}

// /////////////////
NSURL* appURL = [self appUrl];

if (appURL) {
NSURLRequest* appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
[self.webViewEngine loadRequest:appReq];
} else {
NSString* loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.", self.wwwFolderName, self.startPage];
NSLog(@"%@", loadErr);

NSURL* errorUrl = [self errorURL];
if (errorUrl) {
errorUrl = [NSURL URLWithString:[NSString stringWithFormat:@"?error=%@", [loadErr stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLPathAllowedCharacterSet]] relativeToURL:errorUrl];
NSLog(@"%@", [errorUrl absoluteString]);
[self.webViewEngine loadRequest:[NSURLRequest requestWithURL:errorUrl]];
} else {
NSString* html = [NSString stringWithFormat:@"<html><body> %@ </body></html>", loadErr];
[self.webViewEngine loadHTMLString:html baseURL:nil];
}
}
// /////////////////

NSString* bgColorString = [self.settings cordovaSettingForKey:@"BackgroundColor"];
UIColor* bgColor = [self colorFromColorString:bgColorString];
Expand Down

0 comments on commit 4eb3e07

Please sign in to comment.