File tree Expand file tree Collapse file tree
navigation/navigation-common/src
androidTest/java/androidx/navigation
main/java/androidx/navigation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -250,9 +250,8 @@ class NavDestinationAndroidTest {
250250 val destination = NoOpNavigator ().createDestination()
251251 destination.addArgument(" testString" , stringArgument())
252252 destination.addDeepLink(" android-app://androidx.navigation.test/{testString}" )
253- val deepLink = Uri .parse(" android-app://androidx.navigation.test/test" )
254- destination.addDeepLink(deepLink.toString())
255253
254+ val deepLink = Uri .parse(" android-app://androidx.navigation.test/test" )
256255 assertWithMessage(" Deep link should match" )
257256 .that(destination.hasDeepLink(deepLink)).isTrue()
258257 }
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public class NavDeepLink internal constructor(
4747 */
4848 public val mimeType : String?
4949) {
50- private val arguments = mutableListOf<String >()
50+ internal val arguments = mutableListOf<String >()
5151 private val paramArgMap = mutableMapOf<String , ParamQuery >()
5252 private var pattern: Pattern ? = null
5353 private var isParameterizedQuery = false
Original file line number Diff line number Diff line change @@ -312,6 +312,14 @@ public open class NavDestination(
312312 * @see NavController.navigate
313313 */
314314 public fun addDeepLink (navDeepLink : NavDeepLink ) {
315+ val missingRequiredArguments = arguments.filterValues { ! it.isDefaultValuePresent }
316+ .keys
317+ .filter { it !in navDeepLink.arguments }
318+ require(missingRequiredArguments.isEmpty()) {
319+ " Deep link ${navDeepLink.uriPattern} can't be used to open destination $this .\n " +
320+ " Following required arguments are missing: $missingRequiredArguments "
321+ }
322+
315323 deepLinks.add(navDeepLink)
316324 }
317325
You can’t perform that action at this time.
0 commit comments