Skip to content

Commit

Permalink
Fix PDF's no longer opening inline
Browse files Browse the repository at this point in the history
  • Loading branch information
joelekstrom committed Jan 26, 2021
1 parent 8f24f15 commit 8567791
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Fastmate.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.6.3;
MARKETING_VERSION = 1.6.4;
PRODUCT_BUNDLE_IDENTIFIER = io.ekstrom.Fastmate;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -364,7 +364,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.6.3;
MARKETING_VERSION = 1.6.4;
PRODUCT_BUNDLE_IDENTIFIER = io.ekstrom.Fastmate;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
12 changes: 11 additions & 1 deletion Fastmate/WebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,17 @@ - (BOOL)isDownloadRequest:(NSURLRequest *)request
BOOL hasDownloadQueryItem = [components.queryItems indexOfObjectPassingTest:^BOOL(NSURLQueryItem *item, NSUInteger index, BOOL *stop) {
return [item.name isEqualToString:@"download"] && [item.value isEqualToString:@"1"];
}] != NSNotFound;
return hasDownloadQueryItem || [components.path hasPrefix:@"/jmap/download/"];

if (hasDownloadQueryItem) {
return YES;
}

// We want to display PDF's inline if it wasn't a specific request for download
if ([components.path hasSuffix:@".pdf"]) {
return NO;
}

return [components.path hasPrefix:@"/jmap/download/"];
}

- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures {
Expand Down

0 comments on commit 8567791

Please sign in to comment.