File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
commonMain/kotlin/dev/dimension/flare/common/deeplink
commonTest/kotlin/dev/dimension/flare/common/deeplink Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -62,10 +62,11 @@ internal class DeepLinkMatcher<T>(
6262 // match queries (if any)
6363 request.queries.forEach { query ->
6464 val name = query.key
65- val queryStringParser = deepLinkPattern.queryValueParsers[name]
65+ // if the query param is not part of the pattern, we just ignore it
66+ val queryStringParser = deepLinkPattern.queryValueParsers[name] ? : return @forEach
6667 val queryParsedValue =
6768 try {
68- queryStringParser!! .invoke(query.value.first())
69+ queryStringParser.invoke(query.value.first())
6970 } catch (e: IllegalArgumentException ) {
7071 DebugRepository .log(
7172 " ${TAG_LOG_ERROR } : Failed to parse query name:[$name ] value:[${query.value} ]." +
Original file line number Diff line number Diff line change @@ -109,6 +109,28 @@ class DeepLinkMatcherTest {
109109 assertNull(match)
110110 }
111111
112+ @Test
113+ fun ignoresUnknownQueryParameters () {
114+ val patternUrl =
115+ URLBuilder (" https://example.com" )
116+ .apply { path(" test" , " {param}" ) }
117+ .build()
118+ val requestUrl =
119+ URLBuilder (" https://example.com" )
120+ .apply {
121+ path(" test" , " param_value" )
122+ parameters.append(" q" , " test" )
123+ }.build()
124+ val pattern = DeepLinkPattern (TestParamKey .serializer(), patternUrl)
125+ val request = DeepLinkRequest (requestUrl)
126+
127+ val match = DeepLinkMatcher (request, pattern).match()
128+
129+ assertNotNull(match)
130+ assertEquals(TestParamKey .serializer(), match.serializer)
131+ assertEquals(mapOf (" param" to " param_value" ), match.args)
132+ }
133+
112134 @Serializable
113135 private data class HomeKey (
114136 val value : String = " " ,
@@ -120,4 +142,9 @@ class DeepLinkMatcherTest {
120142 val includeHistory : Boolean = false ,
121143 val page : Long = 0 ,
122144 )
145+
146+ @Serializable
147+ private data class TestParamKey (
148+ val param : String ,
149+ )
123150}
You can’t perform that action at this time.
0 commit comments