urls: Generate narrow links in frontend with "channel" operator.

Fixes #30385.
This commit is contained in:
Lauryn Menard
2024-10-03 18:37:58 +02:00
committed by Tim Abbott
parent 70ab893d34
commit d3987f611c
17 changed files with 94 additions and 109 deletions

View File

@@ -36,11 +36,11 @@ export function get_current_hash_section(): string {
export function is_same_server_message_link(url: string): boolean {
// A same server message link always has category `narrow`,
// section `stream` or `dm`, and ends with `/near/<message_id>`,
// section `channel` or `dm`, and ends with `/near/<message_id>`,
// where <message_id> is a sequence of digits.
return (
get_hash_category(url) === "narrow" &&
(get_hash_section(url) === "stream" || get_hash_section(url) === "dm") &&
(get_hash_section(url) === "channel" || get_hash_section(url) === "dm") &&
get_nth_hash_section(url, -2) === "near" &&
/^\d+$/.test(get_nth_hash_section(url, -1))
);