From 2393ae3ce5a901e2531ab3a9172019cfed71c89d Mon Sep 17 00:00:00 2001 From: mau Date: Sat, 21 Sep 2024 20:42:51 +0900 Subject: [PATCH] wip --- .../runtime/data/customjson/ApplyClickableImage.kt | 7 ++----- .../runtime/data/customjson/ApplyClickableImageSpec.kt | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/ApplyClickableImage.kt b/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/ApplyClickableImage.kt index a45b974d..b7afbebf 100644 --- a/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/ApplyClickableImage.kt +++ b/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/ApplyClickableImage.kt @@ -19,11 +19,8 @@ internal fun UiMessage.applyCustomClickableImage(clickableImage: ClickableImage? return false } - return if (this.startsWith("http")) { - Regex("https://.*").matches(this) - } else { - Regex(".*://.*").matches(this) - } + val allowedPattern = Regex("https://.*|.*://.*") + return this.matches(allowedPattern) } @SuppressWarnings("ComplexCondition") diff --git a/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/ApplyClickableImageSpec.kt b/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/ApplyClickableImageSpec.kt index a3ee88c3..4584f8a0 100644 --- a/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/ApplyClickableImageSpec.kt +++ b/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/ApplyClickableImageSpec.kt @@ -31,7 +31,7 @@ class ApplyClickableImageSpec { uiMessage = message.applyCustomClickableImage(ClickableImage("ogle.124dsefsd"), false) uiMessage shouldBeEqualTo message - uiMessage = message.applyCustomClickableImage(ClickableImage("http://test.com"), false) + uiMessage = message.applyCustomClickableImage(ClickableImage("intent:/invalid/deeplink"), false) uiMessage shouldBeEqualTo message uiMessage = message.applyCustomClickableImage(ClickableImage(" myapp://open"), false)