Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #57 from peterjosling/feature/url_loading_fix
Browse files Browse the repository at this point in the history
Fix Messenger.com opening in browser on launch
  • Loading branch information
danielbuechele committed Apr 15, 2015
2 parents 348090f + 3b6b1df commit 0de0aa2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Goofy/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKUIDe

func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: ((WKNavigationActionPolicy) -> Void)) {

var inAppURLs : Array = ["messenger.com/login","messenger.com/t"]

if let nav = navigationAction.request.URL!.absoluteString {
let inApp = inAppURLs.reduce(false, combine: { result, url in result || nav.rangeOfString(url) != nil })
if let url = navigationAction.request.URL {
var inApp = url.host!.hasSuffix("messenger.com") && !url.path!.hasPrefix("/l.php");
var isLogin = url.host!.hasSuffix("facebook.com") && (url.path!.hasPrefix("/login") || url.path!.hasPrefix("/checkpoint"));

if inApp {
if inApp || isLogin {
decisionHandler(.Allow)
} else {
NSWorkspace.sharedWorkspace().openURL(navigationAction.request.URL!)
decisionHandler(.Cancel)
}
}

}

func webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) {
Expand Down

0 comments on commit 0de0aa2

Please sign in to comment.