Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
filter: Use Intl.ListFormat rather than .join(", ").
CIC4DAcaa2dbbba4e5
diff --git a/web/src/filter.ts b/web/src/filter.tsindex 832ea313e24..96bc742954c 100644--- a/web/src/filter.ts+++ b/web/src/filter.ts@@ -976,11 +976,7 @@ export class Filter {}return person.full_name;});-- // We use join to handle the addition of a comma and space after every name- // and also to ensure that we return a string and not an array so that we- // can have the same return type as other cases.- return names.join(", ");+ return util.format_array_as_list(names, "long", "conjunction");}if (term_types.length === 1 && _.isEqual(term_types, ["sender"])) {const email = this.operands("sender")[0];diff --git a/web/tests/filter.test.js b/web/tests/filter.test.jsindex 4f65917852f..7b8462a44f0 100644--- a/web/tests/filter.test.js+++ b/web/tests/filter.test.js@@ -1495,7 +1495,11 @@ test("navbar_helpers", () => {// make sure title has names separated with correct delimitersfunction properly_separated_names(names) {- return names.join(", ");+ const names_internationalized = new Intl.ListFormat("en", {+ style: "long",+ type: "conjunction",+ }).format(names);+ return names_internationalized;}function test_redirect_url_with_search(test_case) {@@ -1709,7 +1713,7 @@ test("navbar_helpers", () => {terms: dm_group_including_guest,is_common_narrow: true,icon: "envelope",- title: "translated: alice (guest), joe",+ title: "translated: alice (guest) and joe",redirect_url_with_search: "/#narrow/dm/" + joe.user_id + "," + alice.user_id + "-group",},{