Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
Do not add query values to the parameter map
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsleyadio committed Mar 15, 2019
1 parent 6b6d555 commit eb8eb90
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
6 changes: 0 additions & 6 deletions deeplink/src/main/java/com/hellofresh/deeplink/BaseRoute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ abstract class BaseRoute<out T>(private vararg val routes: String) : Action<T> {
routePart != inPart -> return@forEach
}
}
uri.queryParameterNames()
.filter { it !in params }
.forEach { key ->
val queryValue = uri.queryParameter(key) ?: error("""Query "$key" has a null value!""")
params[key] = queryValue
}
return MatchResult(true, params)
}
return MatchResult(false)
Expand Down
31 changes: 0 additions & 31 deletions deeplink/src/test/java/com/hellofresh/deeplink/BaseRouteTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package com.hellofresh.deeplink

import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertTrue

Expand Down Expand Up @@ -102,14 +101,6 @@ class BaseRouteTest {
assertFalse(NamelessPathRoute.matchWith(uri).isMatch)
}

@Test
fun matchWith_UriWithNullQueryValue_ThrowsException() {
assertFailsWith<IllegalStateException> {
val uri = DeepLinkUri.parse("http://www.hellofresh.com/recipe/1234?q")
TestRoute.matchWith(uri)
}
}

@Test
fun matchWith_InputWithOnlyPathParams_ReturnsPathData() {
val uri = DeepLinkUri.parse("http://www.hellofresh.com/recipe/1234")
Expand All @@ -119,28 +110,6 @@ class BaseRouteTest {
assertEquals("1234", params["id"])
}

@Test
fun matchWith_InputWithBothPathAndQueryParamsNoClash_ReturnsMixData() {
val uri = DeepLinkUri.parse("http://www.hellofresh.com/recipe/1234?token=XYZ")
val params = TestRoute.matchWith(uri).params

assertEquals(2, params.size)
assertEquals("1234", params["id"])
assertEquals("XYZ", params["token"])
}

@Test
fun matchWith_InputWithBothPathAndQueryParamsClash_ReturnsMixDataWithPathPreferred() {
val uri = DeepLinkUri.parse("http://www.hellofresh.com/recipe/1234?token=XYZ&id=5678")
val params = TestRoute.matchWith(uri).params

assertEquals(2, params.size)
assertEquals("1234", params["id"])
assertEquals("XYZ", params["token"])
// Query value can still be retrieved directly from the URI
assertEquals("5678", uri.queryParameter("id"))
}

@Test
fun matchWith_DefaultPathResolution() {
val uri = DeepLinkUri.parse("http://www.hellofresh.com/recipe/1234")
Expand Down

0 comments on commit eb8eb90

Please sign in to comment.