Skip to content

Commit e617802

Browse files
committed
internal_links: Add Variable realmUrlWithSlash to add '/'
updates the URL construction to include a trailing slash before the fragment identifier This ensures that the URL is properly formatted and makes the url likified. Fixes: #845
1 parent 34da52f commit e617802

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/model/internal_link.dart

+5-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ String? decodeHashComponent(String str) {
5959
Uri narrowLink(PerAccountStore store, Narrow narrow, {int? nearMessageId}) {
6060
// TODO(server-7)
6161
final apiNarrow = resolveDmElements(
62-
narrow.apiEncode(), store.connection.zulipFeatureLevel!);
62+
narrow.apiEncode(), store.connection.zulipFeatureLevel!);
6363
final fragment = StringBuffer('narrow');
6464
for (ApiNarrowElement element in apiNarrow) {
6565
fragment.write('/');
@@ -95,8 +95,11 @@ Uri narrowLink(PerAccountStore store, Narrow narrow, {int? nearMessageId}) {
9595
if (nearMessageId != null) {
9696
fragment.write('/near/$nearMessageId');
9797
}
98+
final realmUrlWithSlash = store.realmUrl.path.endsWith('/')
99+
? store.realmUrl
100+
: store.realmUrl.replace(path: '${store.realmUrl.path}/');
98101

99-
return store.realmUrl.replace(fragment: fragment.toString());
102+
return realmUrlWithSlash.replace(fragment: fragment.toString());
100103
}
101104

102105
/// A [Narrow] from a given URL, on `store`'s realm.

0 commit comments

Comments
 (0)