Bad interpretation of multiple deeplink hosts?
sgioia9 opened this issue · comments
When there are multiple hosts declared, the current behaviour is to create one intent filter, with multiple data
elements:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="$DEEPLINK_SCHEME" android:host="$DEEPLINK_HOST" android:pathPrefix="$ANDROID_PATH_PREFIX" />
<data android:scheme="$DEEPLINK_2_SCHEME" android:host="$DEEPLINK_2_HOST" android:pathPrefix="$ANDROID_2_PATH_PREFIX" />
<data android:scheme="$DEEPLINK_3_SCHEME" android:host="$DEEPLINK_3_HOST" android:pathPrefix="$ANDROID_3_PATH_PREFIX" />
<data android:scheme="$DEEPLINK_4_SCHEME" android:host="$DEEPLINK_4_HOST" android:pathPrefix="$ANDROID_4_PATH_PREFIX" />
<data android:scheme="$DEEPLINK_5_SCHEME" android:host="$DEEPLINK_5_HOST" android:pathPrefix="$ANDROID_5_PATH_PREFIX" />
</intent-filter>
However, my take is that this results in unexpected behavior when what one wants is to allow multiple deeplinks from different hosts and paths.
From the docs:
Although it's possible to include multiple <data> elements in the same filter,
it's important that you create separate filters when your intention is to declare
unique URLs (such as a specific combination of scheme and host), because multiple
<data> elements in the same intent filter are actually merged together to account
for all variations of their combined attributes.
E.g
If I were to write something like
<intent-filter>
<data host="foo.com" pathPrefix="/" />
<data host="bar.com" pathPrefix="baz" />
</intent-filter>
I would expect to only allow deeplinks from foo.com/... and bar.com/baz...., but the actual behavior is that we're allowing:
foo.com/..., foo.com/baz...., bar.com/..., and bar.com/baz....
I'm guessing the solution here is to simply create multiple intent filters for each deeplink variable combo.