Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOB-8537] updates action runner logic to check allowed protocols #769

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
33 changes: 19 additions & 14 deletions swift-sdk/Internal/ActionRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,28 @@ struct ActionRunner {
customActionHandler: CustomActionHandler? = nil,
urlOpener: UrlOpenerProtocol? = nil,
allowedProtocols: [String] = []) -> Bool {
let handled = callExternalHandlers(action: action,
from: context.source,
urlHandler: urlHandler,
customActionHandler: customActionHandler)

if handled {
guard case let .openUrl(url) = detectActionType(fromAction: action),
shouldOpenUrl(url: url, from: context.source, withAllowedProtocols: allowedProtocols) else {
return false
}

if case let handled = callExternalHandlers(action: action,
from: context.source,
urlHandler: urlHandler,
customActionHandler: customActionHandler), handled {
return true
}

if case let .openUrl(url) = detectActionType(fromAction: action),
let urlOpener = urlOpener {
urlOpener.open(url: url)
return true
} else {
if case let .openUrl(url) = detectActionType(fromAction: action),
shouldOpenUrl(url: url, from: context.source, withAllowedProtocols: allowedProtocols),
let urlOpener = urlOpener {
urlOpener.open(url: url)
return true
} else {
return false
}
}

return false


}

// MARK: - Private
Expand Down
Loading