mirror of https://github.com/zulip/zulip.git
topic_link_util: Add `&` as a character which can produce broken links.
`&` in topic names like `©` can result in broken stream topic links. So we generate fallback markdown links for them too. This is a follow up to #30071.
This commit is contained in:
parent
f7750a07a2
commit
6956947a73
|
@ -4,7 +4,7 @@ import * as internal_url from "../shared/src/internal_url";
|
|||
|
||||
import * as stream_data from "./stream_data";
|
||||
|
||||
const invalid_stream_topic_regex = /[*>`]|(\$\$)/g;
|
||||
const invalid_stream_topic_regex = /[`>*&]|(\$\$)/g;
|
||||
|
||||
export function will_produce_broken_stream_topic_link(word: string): boolean {
|
||||
return invalid_stream_topic_regex.test(word);
|
||||
|
@ -24,6 +24,8 @@ export function escape_invalid_stream_topic_characters(text: string): string {
|
|||
return ">";
|
||||
case "*":
|
||||
return "*";
|
||||
case "&":
|
||||
return "&";
|
||||
case "$$":
|
||||
return "$$";
|
||||
default:
|
||||
|
|
|
@ -83,6 +83,11 @@ run_test("stream_topic_link_syntax_test", () => {
|
|||
"[#$$MONEY$$](#narrow/channel/6-.24.24MONEY.24.24)",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
topic_link_util.get_stream_topic_link_syntax("#**Sweden>&ab", "&ab"),
|
||||
"[#Sweden>&ab](#narrow/channel/1-Sweden/topic/.26ab)",
|
||||
);
|
||||
|
||||
// Only for full coverage of the module.
|
||||
assert.equal(topic_link_util.escape_invalid_stream_topic_characters("Sweden"), "Sweden");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue