Android Navigation Deep Link - 忽略查询 [英] Android Navigation Deep Link - Ignore Query
问题描述
我正在尝试为具有以下格式的 URL 添加深层链接:
这会导致传递给我的目的地的 slug
参数也包括查询(如果存在).例如,URL my.example.com/articles/recent-article?utm=1
导致 slug
参数为 recent-article?utm=1
.
我尝试使用以下模式格式试图忽略查询,但 URL 不再正确匹配.
有没有办法有效地忽略查询?
假设您使用的是最新的 Navigation 2.2.0-rc04(或添加对查询参数的支持的其他 Navigation 2.2 版本之一),听起来像您遇到了这个问题,其中没有查询参数的深层链接不会忽略查询参数.>
错误中提到的解决方法是包含一个虚拟参数:
I'm attempting to add a deep-link for a URL that has the following format:
<deepLink
android:id="@+id/deep_link"
android:autoVerify="true"
app:uri="my.example.com/articles/{slug}" />
This causes the slug
argument passed to my destination to also include the query if it exists. For example, the URL my.example.com/articles/recent-article?utm=1
results in the slug
argument being recent-article?utm=1
.
I've tried using the following pattern format in an attempt to ignore the query, but URLs no longer match correctly.
<deepLink
android:id="@+id/deep_link"
android:autoVerify="true"
app:uri="my.example.com/articles/{slug}?*.*" />
Is there a way to effectively ignore the query?
Assuming you're using the latest Navigation 2.2.0-rc04 (or one of the other Navigation 2.2 releases that adds support for query parameters), it sounds like you're hitting this issue where deeplinks without query parameters don't ignore query parameters.
The workaround mentioned in the bug is to include a dummy parameter:
<deepLink
android:id="@+id/deep_link"
android:autoVerify="true"
app:uri="my.example.com/articles/{slug}?dummy={dummy} />
这篇关于Android Navigation Deep Link - 忽略查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!