-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Navigation] Fix deeplink domain parsing being case sensitive #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Navigation] Fix deeplink domain parsing being case sensitive #144
Conversation
navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
Outdated
Show resolved
Hide resolved
navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
Outdated
Show resolved
Hide resolved
navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
Outdated
Show resolved
Hide resolved
navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
Outdated
Show resolved
Hide resolved
navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
Outdated
Show resolved
Hide resolved
navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
Outdated
Show resolved
Hide resolved
@@ -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) |
There was a problem hiding this comment.
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.
Thanks for fixing this! |
Proposed Changes
The current regex pattern matcher was doing a case sensitive check of the domain and arguments. Simply changing it to case insensitive seems to be all that's required to fix this bug. It is important that parameters are still case sensitive but this is still the case as parameter matching is done by the
Uri
code not theNavDeepLink
code. I have written tests to cover these cases.If it is deemed too risky to just run the pattern matcher with
CASE_INSENSITIVE
I believe the regex will have to be redesigned not to use\Q\E
.Testing
adb shell am start -a android.intent.action.VIEW -d https://www.Iana.org/domains/second
Test: /gradlew test connectedCheck
Issues Fixed
https://issuetracker.google.com/issues/153829033
Fixes: b/153829033