Skip to content

Commit

Permalink
internalLinks [nfc]: Inline internal_url.by_stream{,_topic}_url
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chrisbobbe committed Apr 24, 2024
1 parent 4e86013 commit c5b7a78
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/internalLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ export const getStreamTopicUrl = (
streamsById: Map<number, Stream>,
): URL => {
const maybe_get_stream_name = id => streamsById.get(id)?.name;
const path = internal_url.by_stream_topic_url(streamId, topic, maybe_get_stream_name);
const encodedStreamId = internal_url.encode_stream_id(streamId, maybe_get_stream_name);
const encodedTopic = internal_url.encodeHashComponent(topic);
const path = `#narrow/stream/${encodedStreamId}/topic/${encodedTopic}`;
return new URL(path, realm);
};

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

Expand Down

0 comments on commit c5b7a78

Please sign in to comment.