Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
people: Fix small avatar URL generation.
Anders Kaseorgcab0f9c219df
diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.jsindex 8751a13c7cf..be21a2be979 100644--- a/frontend_tests/node_tests/composebox_typeahead.js+++ b/frontend_tests/node_tests/composebox_typeahead.js@@ -879,7 +879,7 @@ test("initialize", ({override, mock_template}) => {actual_value = options.highlighter.call(fake_this, othello);expected_value =` <span class="user_circle_empty user_circle"></span>\n` +- ` <img class="typeahead-image" src="/avatar/${othello.user_id}&s=50" />\n` ++ ` <img class="typeahead-image" src="http://zulip.zulipdev.com/avatar/${othello.user_id}?s=50" />\n` +`<strong>Othello, the Moor of Venice</strong> \n` +`<small class="autocomplete_secondary">[email protected]</small>\n`;assert.equal(actual_value, expected_value);diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.jsindex f835870ba01..59780d012ed 100644--- a/frontend_tests/node_tests/people.js+++ b/frontend_tests/node_tests/people.js@@ -171,7 +171,7 @@ const charles = {email: "[email protected]",user_id: 301,full_name: "Charles Dickens",- avatar_url: "charles.com/foo.png",+ avatar_url: "http://charles.com/foo.png",is_guest: false,};@@ -710,7 +710,7 @@ test_people("message_methods", () => {muted_users.add_muted_user(30);assert.deepEqual(people.sender_info_for_recent_topics_row([30]), [{- avatar_url_small: "/avatar/30&s=50",+ avatar_url_small: "http://zulip.zulipdev.com/avatar/30?s=50",is_muted: true,email: "[email protected]",full_name: me.full_name,@@ -732,7 +732,7 @@ test_people("message_methods", () => {assert.equal(people.pm_with_url(message), "#narrow/pm-with/301,302-group");assert.equal(people.pm_perma_link(message), "#narrow/pm-with/30,301,302-group");assert.equal(people.pm_reply_to(message), "[email protected],[email protected]");- assert.equal(people.small_avatar_url(message), "charles.com/foo.png&s=50");+ assert.equal(people.small_avatar_url(message), "http://charles.com/foo.png?s=50");message = {type: "private",@@ -742,7 +742,7 @@ test_people("message_methods", () => {assert.equal(people.pm_with_url(message), "#narrow/pm-with/302-athens");assert.equal(people.pm_perma_link(message), "#narrow/pm-with/30,302-pm");assert.equal(people.pm_reply_to(message), "[email protected]");- assert.equal(people.small_avatar_url(message), "legacy.png&s=50");+ assert.equal(people.small_avatar_url(message), "http://zulip.zulipdev.com/legacy.png?s=50");message = {avatar_url: undefined,@@ -767,7 +767,10 @@ test_people("message_methods", () => {message = {sender_id: ashton.user_id,};- assert.equal(people.small_avatar_url(message), `/avatar/${ashton.user_id}&s=50`);+ assert.equal(+ people.small_avatar_url(message),+ `http://zulip.zulipdev.com/avatar/${ashton.user_id}?s=50`,+ );message = {type: "private",diff --git a/frontend_tests/node_tests/user_pill.js b/frontend_tests/node_tests/user_pill.jsindex 05f1b5b07de..380ac31d426 100644--- a/frontend_tests/node_tests/user_pill.js+++ b/frontend_tests/node_tests/user_pill.js@@ -33,7 +33,7 @@ const isaac_item = {type: "user",user_id: isaac.user_id,deactivated: false,- img_src: `/avatar/${isaac.user_id}&s=50`,+ img_src: `http://zulip.zulipdev.com/avatar/${isaac.user_id}?s=50`,};let pill_widget = {};diff --git a/static/js/people.js b/static/js/people.jsindex 49b3c85257e..e349d7805cc 100644--- a/static/js/people.js+++ b/static/js/people.js@@ -619,8 +619,9 @@ export function exclude_me_from_string(user_ids_string) {}export function format_small_avatar_url(raw_url) {- const url = raw_url + "&s=50";- return url;+ const url = new URL(raw_url, location);+ url.search += (url.search ? "&" : "") + "s=50";+ return url.href;}export function sender_is_bot(message) {