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.

minor: Check if typeahead query exists.

Ganesh Pawar947ce2b79de2
diff --git a/frontend_tests/node_tests/typeahead.js b/frontend_tests/node_tests/typeahead.js
index 6cca3f9ce7c..aa2163279ff 100644
--- a/frontend_tests/node_tests/typeahead.js
+++ b/frontend_tests/node_tests/typeahead.js
@@ -111,6 +111,22 @@ run_test("triage", () => {
rest: [alice, alicia, steve, stephanie],
},
);
+
+ assert.deepEqual(
+ typeahead.triage(" ", names, (r) => r.name),
+ {
+ matches: [],
+ rest: [alice, alicia, joan, jo, steve, stephanie],
+ },
+ );
+
+ assert.deepEqual(
+ typeahead.triage(";", names, (r) => r.name),
+ {
+ matches: [],
+ rest: [alice, alicia, joan, jo, steve, stephanie],
+ },
+ );
});
run_test("sort_emojis th", () => {
diff --git a/static/shared/js/typeahead.js b/static/shared/js/typeahead.js
index cf04671cfe1..8dc05f87f05 100644
--- a/static/shared/js/typeahead.js
+++ b/static/shared/js/typeahead.js
@@ -129,7 +129,7 @@ export function triage(query, objs, get_item) {
const beginswithCaseSensitive = [];
const beginswithCaseInsensitive = [];
const noMatch = [];
- const lowerQuery = query.toLowerCase();
+ const lowerQuery = query ? query.toLowerCase() : "";
for (const obj of objs) {
const item = get_item(obj);