diff --git a/turbo/src/main/kotlin/dev/hotwire/turbo/nav/TurboNavRule.kt b/turbo/src/main/kotlin/dev/hotwire/turbo/nav/TurboNavRule.kt index 3b89d1b4..34d779a4 100644 --- a/turbo/src/main/kotlin/dev/hotwire/turbo/nav/TurboNavRule.kt +++ b/turbo/src/main/kotlin/dev/hotwire/turbo/nav/TurboNavRule.kt @@ -137,6 +137,6 @@ internal class TurboNavRule( return false } - return URI(first).path == URI(second).path + return Uri.parse(first).path == Uri.parse(second).path } } diff --git a/turbo/src/test/kotlin/dev/hotwire/turbo/nav/TurboNavRuleTest.kt b/turbo/src/test/kotlin/dev/hotwire/turbo/nav/TurboNavRuleTest.kt index 064d61e8..a8c46660 100644 --- a/turbo/src/test/kotlin/dev/hotwire/turbo/nav/TurboNavRuleTest.kt +++ b/turbo/src/test/kotlin/dev/hotwire/turbo/nav/TurboNavRuleTest.kt @@ -37,6 +37,7 @@ class TurboNavRuleTest { private val refreshUrl = "https://hotwired.dev/custom/refresh" private val resumeUrl = "https://hotwired.dev/custom/resume" private val modalRootUrl = "https://hotwired.dev/custom/modal" + private val filterUrl = "https://hotwired.dev/feature?filter=true" private val webDestinationId = 1 private val webModalDestinationId = 2 @@ -250,6 +251,28 @@ class TurboNavRuleTest { assertThat(rule.newNavOptions).isEqualTo(navOptions) } + @Test + fun `navigate to the same path with query params`() { + controller.navigate(webDestinationId, locationArgs(featureUrl)) + val rule = getNavigatorRule(filterUrl) + + // Current destination + assertThat(rule.previousLocation).isEqualTo(homeUrl) + assertThat(rule.currentLocation).isEqualTo(featureUrl) + assertThat(rule.currentPresentationContext).isEqualTo(TurboNavPresentationContext.DEFAULT) + assertThat(rule.isAtStartDestination).isFalse() + + // New destination + assertThat(rule.newLocation).isEqualTo(filterUrl) + assertThat(rule.newPresentationContext).isEqualTo(TurboNavPresentationContext.DEFAULT) + assertThat(rule.newPresentation).isEqualTo(TurboNavPresentation.REPLACE) + assertThat(rule.newNavigationMode).isEqualTo(TurboNavMode.IN_CONTEXT) + assertThat(rule.newModalResult).isNull() + assertThat(rule.newDestinationUri).isEqualTo(webUri) + assertThat(rule.newDestination).isNotNull() + assertThat(rule.newNavOptions).isEqualTo(navOptions) + } + private fun getNavigatorRule( location: String, visitOptions: TurboVisitOptions = TurboVisitOptions(),