Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1049,4 +1049,66 @@ class NavDeepLinkTest {
.that(matchArgs?.getInt("id"))
.isEqualTo(id)
}

@Test
fun deepLinkCaseInsensitiveDomainWithPath() {
val deepLinkArgument = "$DEEP_LINK_EXACT_HTTPS/users/{id}/posts"
val deepLink = NavDeepLink(deepLinkArgument)

val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse("${DEEP_LINK_EXACT_HTTPS.toUpperCase()}/users/$id/posts"),
mapOf("id" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
.isNotNull()
assertWithMessage("Args should contain the id")
.that(matchArgs?.getInt("id"))
.isEqualTo(id)
}

@Test
fun deepLinkCaseInsensitivePath() {
val deepLinkArgument = "$DEEP_LINK_EXACT_HTTPS/users/{id}/posts"
val deepLink = NavDeepLink(deepLinkArgument)

val id = 2
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(
deepLinkArgument
.replace("{id}", id.toString())
.replace("users", "Users")
),
mapOf("id" to intArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
.isNotNull()
assertWithMessage("Args should contain the id")
.that(matchArgs?.getInt("id"))
.isEqualTo(id)
}

@Test
fun deepLinkCaseSensitiveQueryParams() {
val deepLinkString = "$DEEP_LINK_EXACT_HTTP/?myParam={param}"
val deepLink = NavDeepLink(deepLinkString)

val param = 2
val deepLinkUpper = deepLinkString
.replace("myParam", "MYPARAM")
.replace("{param}", param.toString())
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkUpper),
mapOf("param" to intArgument())
)

assertWithMessage("Args should be not be null")
.that(matchArgs)
.isNotNull()
assertWithMessage("Args bundle should be empty")
.that(matchArgs?.isEmpty)
.isTrue()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public class NavDeepLink internal constructor(
// specifically escape any .* instances to ensure
// they are still treated as wildcards in our final regex
val finalRegex = uriRegex.toString().replace(".*", "\\E.*\\Q")
pattern = Pattern.compile(finalRegex)
pattern = Pattern.compile(finalRegex, Pattern.CASE_INSENSITIVE)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianhanniballake Since this is on the finalRegex, it is making the entire pattern including params case insensitive, but based on the test above, it looks like params still aren't matching, which is what we want. Wanted your thoughts on this method, vs always checking the domain in the lowercase or something similar.

}
if (mimeType != null) {
val mimeTypePattern = Pattern.compile("^[\\s\\S]+/[\\s\\S]+$")
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.