Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
refactor isStoreURL check logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonPark committed Sep 8, 2023
1 parent 1b4030f commit 3f5ea7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,14 @@ extension BrowserViewController: WKNavigationDelegate {
// them then iOS will actually first open Safari, which then redirects to the app store. This works but it will
// leave a 'Back to Safari' button in the status bar, which we do not want.
fileprivate func isStoreURL(_ url: URL) -> Bool {
if url.scheme == "http" || url.scheme == "https" {
if url.host == "itunes.apple.com" || url.host == "apps.apple.com" || url.host == "appsto.re" {
return true
}
}
if url.scheme == "itms-appss" || url.scheme == "itms-apps" || url.scheme == "itmss" {
let isStoreScheme = ["itms-apps", "itms-appss", "itmss"].contains(url.scheme)
if isStoreScheme {
return true
}
return false

let isHttpScheme = ["http", "https"].contains(url.scheme)
let isAppStoreHost = ["itunes.apple.com", "apps.apple.com", "appsto.re"].contains(url.host)
return isHttpScheme && isAppStoreHost
}

// This is the place where we decide what to do with a new navigation action. There are a number of special schemes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,14 @@ extension PlaylistWebLoader: WKNavigationDelegate {
// them then iOS will actually first open Safari, which then redirects to the app store. This works but it will
// leave a 'Back to Safari' button in the status bar, which we do not want.
fileprivate func isStoreURL(_ url: URL) -> Bool {
if url.scheme == "http" || url.scheme == "https" {
if url.host == "itunes.apple.com" || url.host == "apps.apple.com" || url.host == "appsto.re" {
return true
}
}
if url.scheme == "itms-appss" || url.scheme == "itms-apps" || url.scheme == "itmss" {
let isStoreScheme = ["itms-apps", "itms-appss", "itmss"].contains(url.scheme)
if isStoreScheme {
return true
}
return false

let isHttpScheme = ["http", "https"].contains(url.scheme)
let isAppStoreHost = ["itunes.apple.com", "apps.apple.com", "appsto.re"].contains(url.host)
return isHttpScheme && isAppStoreHost
}

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

0 comments on commit 3f5ea7b

Please sign in to comment.