You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2012/11/29 20:37:56 UTC

ios commit: [ios] Support startPage as URL. If wwwFolderName or startPage start with 'http://' load resource as if is NSURL

Updated Branches:
  refs/heads/master 2335d32ed -> a952761d0


[ios] Support startPage as URL.  If wwwFolderName or startPage start with 'http://' load resource as if is NSURL


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/a952761d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/a952761d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/a952761d

Branch: refs/heads/master
Commit: a952761d0418c6236da5bfce9c832059535e456f
Parents: 2335d32
Author: Michal Mocny <mm...@gmail.com>
Authored: Tue Nov 27 13:40:26 2012 -0500
Committer: Michal Mocny <mm...@gmail.com>
Committed: Thu Nov 29 14:36:06 2012 -0500

----------------------------------------------------------------------
 CordovaLib/Classes/CDVViewController.m |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/a952761d/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 320391f..1199984 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -170,17 +170,23 @@ static NSString* gOriginalUserAgent = nil;
 {
     [super viewDidLoad];
 
-    NSString* startFilePath = [_commandDelegate pathForResource:self.startPage];
     NSURL* appURL = nil;
     NSString* loadErr = nil;
 
-    if (startFilePath == nil) {
-        loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.", self.wwwFolderName, self.startPage];
-        NSLog(@"%@", loadErr);
-        self.loadFromString = YES;
-        appURL = nil;
+    if ([self.startPage hasPrefix:@"http://"]) {
+        appURL = [NSURL URLWithString:self.startPage];
+    } else if ([self.wwwFolderName hasPrefix:@"http://"]) {
+        appURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", self.wwwFolderName, self.startPage]];
     } else {
-        appURL = [NSURL fileURLWithPath:startFilePath];
+        NSString* startFilePath = [_commandDelegate pathForResource:self.startPage];
+        if (startFilePath == nil) {
+            loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.", self.wwwFolderName, self.startPage];
+            NSLog(@"%@", loadErr);
+            self.loadFromString = YES;
+            appURL = nil;
+        } else {
+            appURL = [NSURL fileURLWithPath:startFilePath];
+        }
     }
 
     // // Fix the iOS 5.1 SECURITY_ERR bug (CB-347), this must be before the webView is instantiated ////