Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
shared: Do not throw exception in parse unicode.
Austin Riba944781e8739b
diff --git a/frontend_tests/node_tests/typeahead.js b/frontend_tests/node_tests/typeahead.jsindex c5525f1bd0c..13c66ddf69f 100644--- a/frontend_tests/node_tests/typeahead.js+++ b/frontend_tests/node_tests/typeahead.js@@ -56,6 +56,11 @@ run_test("get_emoji_matcher", () => {assert_matches("🐼", [emoji_panda_face]);});+run_test("parse_unicode_emoji_code", () => {+ assert.equal(typeahead.parse_unicode_emoji_code("1f43c"), "🐼");+ assert.equal(typeahead.parse_unicode_emoji_code("not_unicode"), undefined);+});+run_test("triage", () => {const alice = {name: "alice"};const alicia = {name: "Alicia"};diff --git a/static/shared/js/typeahead.js b/static/shared/js/typeahead.jsindex b619e3099f2..9d11c94ad5b 100644--- a/static/shared/js/typeahead.js+++ b/static/shared/js/typeahead.js@@ -98,11 +98,18 @@ export function clean_query_lowercase(query) {return query;}-export const parse_unicode_emoji_code = (code) =>- code- .split("-")- .map((hex) => String.fromCodePoint(Number.parseInt(hex, 16)))- .join("");+export const parse_unicode_emoji_code = (code) => {+ try {+ return code+ .split("-")+ .map((hex) => String.fromCodePoint(Number.parseInt(hex, 16)))+ .join("");+ } catch {+ // Code could not be parsed, but instead of throwing an exception+ // we return undefined instead of a string.+ return undefined;+ }+};export function get_emoji_matcher(query) {// replaces spaces with underscores for emoji matching