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.

hash_util: Avoid assertion error when user mistypes the `sender:` URL.

Aman Agrawale6daac963330
diff --git a/web/src/hash_util.ts b/web/src/hash_util.ts
index 399a86b99b0..d7b08c1df12 100644
--- a/web/src/hash_util.ts
+++ b/web/src/hash_util.ts
@@ -81,7 +81,16 @@ export function decode_operand(
if (operator === "sender") {
const user_ids = people.slug_to_user_ids(operand);
- assert(user_ids?.length === 1, "Sender operand should not be a group");
+ if (user_ids?.length !== 1) {
+ // User mistyped the URL since we don't support
+ // group operand for `sender` narrow. Returning
+ // -1 will lead to us showing a proper user
+ // doesn't exist message in the UI.
+ // Other options is to throw an error which will
+ // lead to us showing a "Invalid URL" banner which
+ // is not very nice looking.
+ return -1;
+ }
return util.the(user_ids);
}