people: Fix small avatar URL generation.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-10-13 15:48:32 -07:00 committed by Tim Abbott
parent afa47b9ae3
commit cab0f9c219
4 changed files with 13 additions and 9 deletions

View File

@ -879,7 +879,7 @@ test("initialize", ({override, mock_template}) => {
actual_value = options.highlighter.call(fake_this, othello); actual_value = options.highlighter.call(fake_this, othello);
expected_value = expected_value =
` <span class="user_circle_empty user_circle"></span>\n` + ` <span class="user_circle_empty user_circle"></span>\n` +
` <img class="typeahead-image" src="/avatar/${othello.user_id}&amp;s&#x3D;50" />\n` + ` <img class="typeahead-image" src="http://zulip.zulipdev.com/avatar/${othello.user_id}?s&#x3D;50" />\n` +
`<strong>Othello, the Moor of Venice</strong>&nbsp;&nbsp;\n` + `<strong>Othello, the Moor of Venice</strong>&nbsp;&nbsp;\n` +
`<small class="autocomplete_secondary">othello@zulip.com</small>\n`; `<small class="autocomplete_secondary">othello@zulip.com</small>\n`;
assert.equal(actual_value, expected_value); assert.equal(actual_value, expected_value);

View File

@ -171,7 +171,7 @@ const charles = {
email: "charles@example.com", email: "charles@example.com",
user_id: 301, user_id: 301,
full_name: "Charles Dickens", full_name: "Charles Dickens",
avatar_url: "charles.com/foo.png", avatar_url: "http://charles.com/foo.png",
is_guest: false, is_guest: false,
}; };
@ -710,7 +710,7 @@ test_people("message_methods", () => {
muted_users.add_muted_user(30); muted_users.add_muted_user(30);
assert.deepEqual(people.sender_info_for_recent_topics_row([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, is_muted: true,
email: "me@example.com", email: "me@example.com",
full_name: me.full_name, 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_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_perma_link(message), "#narrow/pm-with/30,301,302-group");
assert.equal(people.pm_reply_to(message), "Athens@example.com,charles@example.com"); assert.equal(people.pm_reply_to(message), "Athens@example.com,charles@example.com");
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 = { message = {
type: "private", 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_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_perma_link(message), "#narrow/pm-with/30,302-pm");
assert.equal(people.pm_reply_to(message), "Athens@example.com"); assert.equal(people.pm_reply_to(message), "Athens@example.com");
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 = { message = {
avatar_url: undefined, avatar_url: undefined,
@ -767,7 +767,10 @@ test_people("message_methods", () => {
message = { message = {
sender_id: ashton.user_id, 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 = { message = {
type: "private", type: "private",

View File

@ -33,7 +33,7 @@ const isaac_item = {
type: "user", type: "user",
user_id: isaac.user_id, user_id: isaac.user_id,
deactivated: false, 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 = {}; let pill_widget = {};

View File

@ -619,8 +619,9 @@ export function exclude_me_from_string(user_ids_string) {
} }
export function format_small_avatar_url(raw_url) { export function format_small_avatar_url(raw_url) {
const url = raw_url + "&s=50"; const url = new URL(raw_url, location);
return url; url.search += (url.search ? "&" : "") + "s=50";
return url.href;
} }
export function sender_is_bot(message) { export function sender_is_bot(message) {