Skip to content

Commit

Permalink
Merge pull request #117 from DrMoriarty/master
Browse files Browse the repository at this point in the history
fix url processing
  • Loading branch information
EddyVerbruggen committed Feb 12, 2016
2 parents d4cfe16 + 0c050be commit 2d7cbc2
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/ios/NativePageTransitions.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -753,17 +753,23 @@ - (BOOL) loadHrefIfPassed:(NSString*) href {
urlParams = [href substringFromIndex:range.location+5];
}
NSURL *url;
NSURL *origUrl;
if (self.wkWebView != nil) {
NSString *filePath = bareFileName;
NSString *replaceWith = [@"/" stringByAppendingString:bareFileName];
filePath = [self.wkWebView.URL.absoluteString stringByReplacingOccurrencesOfString:self.wkWebView.URL.path withString:replaceWith];
url = [NSURL URLWithString:filePath];
origUrl = self.wkWebView.URL;
} else {
NSString *currentUrl = uiwebview.request.URL.absoluteString;
NSRange lastSlash = [currentUrl rangeOfString:@"/" options:NSBackwardsSearch];
NSString *path = [currentUrl substringToIndex:lastSlash.location+1];
url = [NSURL URLWithString:[path stringByAppendingString:bareFileName]];
origUrl = uiwebview.request.URL;
}
if([origUrl.scheme isEqualToString:@"file"]) {
NSString *currentUrl = origUrl.absoluteString;
NSRange lastSlash = [currentUrl rangeOfString:@"/" options:NSBackwardsSearch];
NSString *path = [currentUrl substringToIndex:lastSlash.location+1];
url = [NSURL URLWithString:[path stringByAppendingString:bareFileName]];
} else {
NSString *filePath = bareFileName;
NSString *replaceWith = [@"/" stringByAppendingString:bareFileName];
filePath = [origUrl.absoluteString stringByReplacingOccurrencesOfString:origUrl.path withString:replaceWith];
url = [NSURL URLWithString:filePath];
}

// re-attach the params when loading the url
if (urlParams != nil) {
Expand Down

0 comments on commit 2d7cbc2

Please sign in to comment.