Skip to content

Commit c5b7a78

Browse files
committed
internalLinks [nfc]: Inline internal_url.by_stream{,_topic}_url
This refactor will help with zulip#5861, but Tim has reminded me that we're not ready to address zulip#5861 until a release addressing zulip#5860 (as we did in the previous commit) has been out for a while: https://chat.zulip.org/#narrow/stream/378-api-design/topic/URLs.20for.20stream.20to.20channel.20rename/near/1786615
1 parent 4e86013 commit c5b7a78

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/utils/internalLinks.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ export const getStreamTopicUrl = (
242242
streamsById: Map<number, Stream>,
243243
): URL => {
244244
const maybe_get_stream_name = id => streamsById.get(id)?.name;
245-
const path = internal_url.by_stream_topic_url(streamId, topic, maybe_get_stream_name);
245+
const encodedStreamId = internal_url.encode_stream_id(streamId, maybe_get_stream_name);
246+
const encodedTopic = internal_url.encodeHashComponent(topic);
247+
const path = `#narrow/stream/${encodedStreamId}/topic/${encodedTopic}`;
246248
return new URL(path, realm);
247249
};
248250

@@ -252,7 +254,7 @@ export const getStreamUrl = (
252254
streamsById: Map<number, Stream>,
253255
): URL => {
254256
const maybe_get_stream_name = id => streamsById.get(streamId)?.name;
255-
const path = internal_url.by_stream_url(streamId, maybe_get_stream_name);
257+
const path = `#narrow/stream/${internal_url.encode_stream_id(streamId, maybe_get_stream_name)}`;
256258
return new URL(path, realm);
257259
};
258260

0 commit comments

Comments
 (0)