Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

compose_ui: Test reverse template that does not re-match pattern.

Alex Vandiver959230dd2736
diff --git a/web/tests/compose_ui.test.cjs b/web/tests/compose_ui.test.cjs
index 64b741c233d..509c026d097 100644
--- a/web/tests/compose_ui.test.cjs
+++ b/web/tests/compose_ui.test.cjs
@@ -464,6 +464,20 @@ run_test("reverse_linkify_text", () => {
compose_ui.reverse_linkify_text("https://realm.com/my_realm_filter/abc-ZUL-15"),
"abc-ZUL-15",
);
+
+ // When the reverse template produces text that does not match the
+ // linkifier pattern (here the reverse template omits the leading "#"
+ // required by the pattern), the URL is not shortened even though the
+ // URL template matches the input.
+ linkifiers.update_linkifier_rules([
+ {
+ id: 11,
+ pattern: "#(?P<id>\\d+)",
+ url_template: "https://example.com/issue/{id}",
+ reverse_template: "id-{id}",
+ },
+ ]);
+ assert.equal(compose_ui.reverse_linkify_text("https://example.com/issue/42"), null);
});
run_test("quote_message", ({override, override_rewire}) => {