/
githubmirror
/
zulip
Обзор
Документация
Войти
/
githubmirror
/
zulip
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
web/src/resolved_topic.ts
45 строк
2 KB
Sahil Batra
resolved_topic: Fix comment on RESOLVED_TOPIC_PREFIX_RE.
17 мар 2026, 00:00
17 мар 2026, 00:00
8bbf7c2
Код
Авторство
О чём код?
/** The canonical form of the resolved-topic prefix. */ export const RESOLVED_TOPIC_PREFIX = "✔ "; /** * Pattern for an arbitrary resolved-topic prefix. * * These always begin with the canonical prefix, but can go on longer. */ // The class has the same characters as RESOLVED_TOPIC_PREFIX. // It's designed to remove a weird "✔ ✔✔ " prefix, if present. // Compare build_message_edit_request in zerver/actions/message_edit.py. const RESOLVED_TOPIC_PREFIX_RE = /^✔ [ ✔]*/; export function is_resolved(topic_name: string): boolean { return topic_name.startsWith(RESOLVED_TOPIC_PREFIX); } export function resolve_name(topic_name: string): string { return RESOLVED_TOPIC_PREFIX + topic_name; } /** * The un-resolved form of this topic name. * * If the topic is already not a resolved topic, this is the identity. */ export function unresolve_name(topic_name: string): string { return topic_name.replace(RESOLVED_TOPIC_PREFIX_RE, ""); } /** * Split the topic name for display, into a "resolved" prefix and remainder. * * The prefix is always the canonical resolved-topic prefix, or empty. * * This function is injective: different topics never produce the same * result, even when `unresolve_name` would give the same result. That's a * property we want when listing topics in the UI, so that we don't end up * showing what look like several identical topics. */ export function display_parts(topic_name: string): [string, string] { return is_resolved(topic_name) ? [RESOLVED_TOPIC_PREFIX, topic_name.slice(RESOLVED_TOPIC_PREFIX.length)] : ["", topic_name]; }