Skip to content

Commit

Permalink
Handle about:blank cases (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
markmur authored Oct 18, 2024
1 parent 02d796b commit 773e42b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.1.1 - October 18, 2024

- Ignore "about:blank" URLs

## 3.1.0 - October 16, 2024

- Ignore cancelled redirects
Expand Down
2 changes: 1 addition & 1 deletion ShopifyCheckoutSheetKit.podspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Pod::Spec.new do |s|
s.version = "3.1.0"
s.version = "3.1.1"

s.name = "ShopifyCheckoutSheetKit"
s.summary = "Enables Swift apps to embed the Shopify's highest converting, customizable, one-page checkout."
Expand Down
6 changes: 5 additions & 1 deletion Sources/ShopifyCheckoutSheetKit/CheckoutURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ public struct CheckoutURL {
return false
}

public func isBlank() -> Bool {
return url.scheme == "about" || url.absoluteString == "about:blank"
}

public func isDeepLink() -> Bool {
guard let scheme = url.scheme else {
guard let scheme = url.scheme, !isBlank() else {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO
import UIKit

/// The version of the `ShopifyCheckoutSheetKit` library.
public let version = "3.1.0"
public let version = "3.1.1"

internal var invalidateOnConfigurationChange = true

Expand Down
10 changes: 10 additions & 0 deletions Tests/ShopifyCheckoutSheetKitTests/CheckoutURLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,22 @@ class CheckoutURLTests: XCTestCase {
}

func testIsDeepLink() {
/// Invalid cases
let secureURL = URL(string: "https://shopify.com")!
let nonSecureURL = URL(string: "http://shopify.com")!
let blank = URL(string: "about:blank")!

/// Valid cases
let deeplink = URL(string: "app://deep/link")!
let deeplink2 = URL(string: "notes-app://")!
let deeplink3 = URL(string: "maps://?q=Cupertino")!

XCTAssertFalse(CheckoutURL(from: secureURL).isDeepLink())
XCTAssertFalse(CheckoutURL(from: nonSecureURL).isDeepLink())
XCTAssertFalse(CheckoutURL(from: blank).isDeepLink())

XCTAssertTrue(CheckoutURL(from: deeplink).isDeepLink())
XCTAssertTrue(CheckoutURL(from: deeplink2).isDeepLink())
XCTAssertTrue(CheckoutURL(from: deeplink3).isDeepLink())
}
}

0 comments on commit 773e42b

Please sign in to comment.