Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 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 {
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 {
// For URL actions, validate protocol before proceeding
if case let .openUrl(url) = detectActionType(fromAction: action) {
guard 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 {
Comment on lines +40 to +43
Copy link
Preview

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using case let for a Boolean result is unconventional. Replace if case let handled = ... with let handled = ... outside the if, then if handled { ... } for clarity.

Copilot uses AI. Check for mistakes.

return true
}

if case let .openUrl(url) = detectActionType(fromAction: action),
let urlOpener = urlOpener {
urlOpener.open(url: url)
return true
}

return false
}

// MARK: - Private
Expand Down
6 changes: 3 additions & 3 deletions tests/hosting-apps/ui-tests-app/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ViewController: UIViewController {
ITBInfo()

let html = """
<a href="http://website/resource#something">Click Me</a>
<a href="https://website/resource#something">Click Me</a>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'>
"""
InAppDisplayer.showIterableHtmlMessage(html) { url in
Expand Down Expand Up @@ -104,7 +104,7 @@ class ViewController: UIViewController {

let messageId = "zeeMessageId"
let html = """
<a href="http://website/resource#something">Click Me</a>
<a href="https://website/resource#something">Click Me</a>
"""
let content = IterableHtmlInAppContent(edgeInsets: .zero, html: html)
let message = IterableInAppMessage(messageId: messageId, campaignId: 1234, content: content)
Expand Down Expand Up @@ -170,7 +170,7 @@ class ViewController: UIViewController {

let messageId = "zeeMessageId"
let html = """
<a href="http://website/resource#something">Click Me</a>
<a href="https://website/resource#something">Click Me</a>
"""
let padding = Padding(top: .autoExpand,
left: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class NotificationExtensionTests: XCTestCase {
"openApp": true,
"action": [
"type": "openUrl",
"data": "http://maps.apple.com/?ll=37.7828,-122.3984"
"data": "https://maps.apple.com/?ll=37.7828,-122.3984"
]
],
[
Expand Down Expand Up @@ -383,7 +383,7 @@ class NotificationExtensionTests: XCTestCase {
"title": "Open App",
"action": [
"type": "openUrl",
"data": "http://maps.apple.com/?ll=37.7828,-122.3984"
"data": "https://maps.apple.com/?ll=37.7828,-122.3984"
],
] as [String : Any]],
] as [String : Any],
Expand Down Expand Up @@ -422,7 +422,7 @@ class NotificationExtensionTests: XCTestCase {
"title": "Open App",
"action": [
"type": "openUrl",
"data": "http://maps.apple.com/?ll=37.7828,-122.3984"
"data": "https://maps.apple.com/?ll=37.7828,-122.3984"
],
"actionIcon": [
"iconType": "systemImage",
Expand Down Expand Up @@ -466,7 +466,7 @@ class NotificationExtensionTests: XCTestCase {
"title": "Open App",
"action": [
"type": "openUrl",
"data": "http://maps.apple.com/?ll=37.7828,-122.3984"
"data": "https://maps.apple.com/?ll=37.7828,-122.3984"
],
"actionIcon": [
"iconType": "templateImage",
Expand Down
4 changes: 2 additions & 2 deletions tests/ui-tests/UITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class UITests: XCTestCase {
// }
//
// func testShowInApp1() {
// inAppTest(buttonName: "Show InApp#1", linkName: "Click Me", expectedCallbackUrl: "http://website/resource#something")
// inAppTest(buttonName: "Show InApp#1", linkName: "Click Me", expectedCallbackUrl: "https://website/resource#something")
// }
//
// // Full Screen
Expand All @@ -120,7 +120,7 @@ class UITests: XCTestCase {
//
// // Full Screen
// func testShowInApp4() {
// inAppTest(buttonName: "Show InApp#4", linkName: "Click Me", expectedCallbackUrl: "http://website/resource#something")
// inAppTest(buttonName: "Show InApp#4", linkName: "Click Me", expectedCallbackUrl: "https://website/resource#something")
// }
//
// // Full Screen
Expand Down
8 changes: 4 additions & 4 deletions tests/unit-tests/DeepLinkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class DeepLinkTests: XCTestCase {
super.tearDown()
}

private let iterableRewriteURL = "http://links.iterable.com/a/60402396fbd5433eb35397b47ab2fb83?_e=joneng%40iterable.com&_m=93125f33ba814b13a882358f8e0852e0"
private let iterableNoRewriteURL = "http://links.iterable.com/u/60402396fbd5433eb35397b47ab2fb83?_e=joneng%40iterable.com&_m=93125f33ba814b13a882358f8e0852e0"
private let iterableRewriteURL = "https://links.iterable.com/a/60402396fbd5433eb35397b47ab2fb83?_e=joneng%40iterable.com&_m=93125f33ba814b13a882358f8e0852e0"
private let iterableNoRewriteURL = "https://links.iterable.com/u/60402396fbd5433eb35397b47ab2fb83?_e=joneng%40iterable.com&_m=93125f33ba814b13a882358f8e0852e0"

private let redirectRequest = "https://httpbin.org/redirect-to?url=http://example.com"
private let exampleUrl = "http://example.com"
private let redirectRequest = "https://httpbin.org/redirect-to?url=https://example.com"
private let exampleUrl = "https://example.com"

func testTrackUniversalDeepLinkRewrite() {
let expectation1 = expectation(description: #function)
Expand Down
24 changes: 12 additions & 12 deletions tests/unit-tests/InAppParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class InAppParsingTests: XCTestCase {
saveToInbox: false,
inboxMetadata: nil,
customPayload: nil)
let buttonUrl = "http://somewhere.com"
let buttonUrl = "https://somewhere.com"
let expectation1 = expectation(description: "track in app click")

let networkSession = MockNetworkSession(statusCode: 200)
Expand Down Expand Up @@ -515,7 +515,7 @@ class InAppParsingTests: XCTestCase {
"inAppMessages" : [
{
"content" : {
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>"
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>"
},
"messageId" : "messageId-\(id)",
"campaignId" : \(id)
Expand All @@ -534,7 +534,7 @@ class InAppParsingTests: XCTestCase {
"inAppMessages" : [
{
"content" : {
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>"
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>"
},
"messageId" : "messageId-\(id)",
"campaignId" : \(id),
Expand All @@ -558,7 +558,7 @@ class InAppParsingTests: XCTestCase {
"inAppMessages" : [
{
"content" : {
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>"
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>"
},
"messageId" : "messageId-\(id)",
"campaignId" : \(id),
Expand Down Expand Up @@ -633,31 +633,31 @@ class InAppParsingTests: XCTestCase {
"inAppMessages" : [
{
"content" : {
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>"
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>"
},
"messageId" : "messageId1",
"campaignId" : 1,
"customPayload" : \(customPayload1.toJsonString())
},
{
"content" : {
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>"
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>"
},
"messageId" : "messageId2",
"campaignId" : 2,
"customPayload" : \(customPayload2.toJsonString())
},
{
"content" : {
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>"
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>"
},
"messageId" : "messageId3",
"campaignId" : 3,
"customPayload" : {}
},
{
"content" : {
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>"
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>"
},
"messageId" : "messageId4",
"campaignId" : 4,
Expand Down Expand Up @@ -716,7 +716,7 @@ class InAppParsingTests: XCTestCase {
{
"content" : {
"type" : "html",
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>"
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>"
},
"messageId" : "messageId1",
"campaignId" : 1,
Expand All @@ -731,7 +731,7 @@ class InAppParsingTests: XCTestCase {
"saveToInbox" : true,
"content" : {
"type" : "html",
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>",
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>",
},
"messageId" : "messageId2",
"campaignId" : 2,
Expand All @@ -748,7 +748,7 @@ class InAppParsingTests: XCTestCase {
},
{
"content" : {
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>"
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>"
},
"messageId" : "messageId3",
"campaignId" : 3,
Expand All @@ -760,7 +760,7 @@ class InAppParsingTests: XCTestCase {
},
{
"content" : {
"html" : "<a href=\\"http://somewhere.com\\">Click here</a>"
"html" : "<a href=\\"https://somewhere.com\\">Click here</a>"
},
"messageId" : "messageId4",
"campaignId" : 4,
Expand Down
6 changes: 3 additions & 3 deletions tests/unit-tests/IterableAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1088,14 +1088,14 @@ class IterableAPITests: XCTestCase {
"messageId": "messageId",
"defaultAction": [
"type": "openUrl",
"data": "http://somewhere.com",
"data": "https://somewhere.com",
],
] as [String : Any],
]
let launchOptions: [UIApplication.LaunchOptionsKey: Any] = [UIApplication.LaunchOptionsKey.remoteNotification: userInfo]
let urlDelegate = MockUrlDelegate(returnValue: true)
urlDelegate.callback = { url, _ in
XCTAssertEqual(url.absoluteString, "http://somewhere.com")
XCTAssertEqual(url.absoluteString, "https://somewhere.com")
expectation1.fulfill()
}
let config = IterableConfig()
Expand All @@ -1118,7 +1118,7 @@ class IterableAPITests: XCTestCase {
"isGhostPush": false,
"defaultAction": [
"type": "openUrl",
"data": "http://somewhere.com",
"data": "https://somewhere.com",
],
] as [String : Any],
]
Expand Down