BranchMetrics / android-branch-deep-linking-attribution

The Branch Android SDK for deep linking and attribution. Branch helps mobile apps grow with deep links / deeplinks that power paid acquisition and re-engagement campaigns, referral programs, content sharing, deep linked emails, smart banners, custom user onboarding, and more.
https://docs.branch.io/pages/apps/android/
MIT License
399 stars 156 forks source link

Fix UnsupportedOperationException in parseReferringURL for non-hierarchical URIs #1147

Closed nsingh-branch closed 10 months ago

nsingh-branch commented 10 months ago

Description

Issue: The parseReferringURL function in the ReferringUrlUtility class throws an UnsupportedOperationException with the message "This isn't a hierarchical URI". This error occurs when attempting to access uri.queryParameterNames for a non-hierarchical URI (e.g., app:home), which lacks the structured path and query parameters of a hierarchical URI (e.g., app://home).

Solution: The fix involves adding a check to determine if the URI is hierarchical using uri.isHierarchical() before iterating over uri.queryParameterNames in the for loop. If the URI is found to be non-hierarchical, the function now logs a debug message and bypasses the query parameter parsing logic, preventing the UnsupportedOperationException. There is also a new unit test to properly test this case.

Testing Instructions

Open a test app with a hierarchical and non-hierarchical URI to see the proper behavior and logging.

Risk Assessment [LOW]

Reviewer Checklist (To be checked off by the reviewer only)

cc @BranchMetrics/saas-sdk-devs for visibility.