Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
filter: Resolve a digit-leading channel name to its id.
Evy Kassirer39934ae84e08
diff --git a/web/src/filter.ts b/web/src/filter.tsindex 121c9da1420..d1d81da7df5 100644--- a/web/src/filter.ts+++ b/web/src/filter.ts@@ -490,11 +490,11 @@ export class Filter {}operand = Filter.decodeOperand(parts.join(":"), operator);- // Check for user-entered channel name. If the name is valid,- // convert it to id.+ // Resolve a user-entered channel name to its id. A purely+ // numeric operand is taken to be a stream id already.if ((operator === "channel" || util.is_channel_synonym(operator)) &&- Number.isNaN(Number.parseInt(operand, 10))+ !util.is_numeric_string(operand)) {const sub = stream_data.get_sub(operand);if (sub) {diff --git a/web/tests/filter.test.cjs b/web/tests/filter.test.cjsindex cdeebfa55c3..63f4a8672ea 100644--- a/web/tests/filter.test.cjs+++ b/web/tests/filter.test.cjs@@ -1666,6 +1666,19 @@ test("parse", () => {];_test();+ // A digit-leading channel name resolves by name, not by reading+ // its leading digits as a stream id.+ make_sub("7th", 7000);+ string = "channel:7th";+ terms = [{operator: "channel", operand: "7000"}];+ _test();++ // A digit-leading operand with no matching channel is left as-is,+ // not coerced into a stream id.+ string = "channel:9th";+ terms = [{operator: "channel", operand: "9th"}];+ _test();+string = `channel:${foo_stream_id} topic:bar yo`;terms = [{operator: "channel", operand: foo_stream_id.toString()},