From 2dcfd0307c2bfb1b9a35efce5fc293f6146f5952 Mon Sep 17 00:00:00 2001 From: Iliyan Germanov Date: Thu, 5 Dec 2024 00:29:40 +0200 Subject: [PATCH] Fix URL params decoding (#62) * Fix missing URL decoding * Improve analytics logging --- .../commonMain/kotlin/domain/analytics/Analytics.kt | 2 +- .../jsMain/kotlin/navigation/SystemNavigation.js.kt | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/domain/analytics/Analytics.kt b/composeApp/src/commonMain/kotlin/domain/analytics/Analytics.kt index 3fb95500..8e218746 100644 --- a/composeApp/src/commonMain/kotlin/domain/analytics/Analytics.kt +++ b/composeApp/src/commonMain/kotlin/domain/analytics/Analytics.kt @@ -45,7 +45,7 @@ class Analytics( appScope.launch { // TODO: Optimize later by batching events val paramsJson = Json.encodeToString(params) - logger.info("$TAG Tracking: '$eventName' with $paramsJson params...") + logger.info("$TAG Tracking: '$eventName' with $paramsJson params.") analyticsRepository.logEvent( setOf( AnalyticsEventDto( diff --git a/composeApp/src/jsMain/kotlin/navigation/SystemNavigation.js.kt b/composeApp/src/jsMain/kotlin/navigation/SystemNavigation.js.kt index 425a5936..ee815dbd 100644 --- a/composeApp/src/jsMain/kotlin/navigation/SystemNavigation.js.kt +++ b/composeApp/src/jsMain/kotlin/navigation/SystemNavigation.js.kt @@ -67,10 +67,18 @@ class WebSystemNavigation : SystemNavigation { .split("&") .mapNotNull { val parts = it.split("=") - if (parts.size == 2) parts[0] to parts[1] else null + if (parts.size == 2) { + val key = decodeURIComponent(parts[0]) + val value = decodeURIComponent(parts[1]) + key to value + } else null } .toMap() } + + private fun decodeURIComponent(encoded: String): String { + return js("decodeURIComponent")(encoded) as String + } }