mirror of https://github.com/zulip/zulip.git
hash_util: Rename _uri functions to _url.
It's 2022 and the WHATWG no longer recognizes the term URI. Everything is now a URL or a type of URL. Which is great because it's way less confusing. Details here: https://url.spec.whatwg.org/
This commit is contained in:
parent
b39d47995d
commit
b22578f975
|
@ -350,7 +350,7 @@ test("quote_and_reply", ({override, override_rewire}) => {
|
|||
sender_full_name: "Steve Stephenson",
|
||||
sender_id: 90,
|
||||
};
|
||||
hash_util.by_conversation_and_time_uri = () =>
|
||||
hash_util.by_conversation_and_time_url = () =>
|
||||
"https://chat.zulip.org/#narrow/stream/92-learning/topic/Tornado";
|
||||
|
||||
let success_function;
|
||||
|
|
|
@ -265,7 +265,7 @@ run_test("quote_and_reply", ({override, override_rewire}) => {
|
|||
|
||||
override(
|
||||
hash_util,
|
||||
"by_conversation_and_time_uri",
|
||||
"by_conversation_and_time_url",
|
||||
() => "https://chat.zulip.org/#narrow/stream/92-learning/topic/Tornado",
|
||||
);
|
||||
|
||||
|
|
|
@ -129,15 +129,15 @@ run_test("test_parse_narrow", () => {
|
|||
]);
|
||||
});
|
||||
|
||||
run_test("test_stream_edit_uri", () => {
|
||||
run_test("test_stream_edit_url", () => {
|
||||
const sub = {
|
||||
name: "research & development",
|
||||
stream_id: 42,
|
||||
};
|
||||
assert.equal(hash_util.stream_edit_uri(sub), "#streams/42/research.20.26.20development");
|
||||
assert.equal(hash_util.stream_edit_url(sub), "#streams/42/research.20.26.20development");
|
||||
});
|
||||
|
||||
run_test("test_by_conversation_and_time_uri", () => {
|
||||
run_test("test_by_conversation_and_time_url", () => {
|
||||
let message = {
|
||||
type: "stream",
|
||||
stream_id: frontend.stream_id,
|
||||
|
@ -146,7 +146,7 @@ run_test("test_by_conversation_and_time_uri", () => {
|
|||
};
|
||||
|
||||
assert.equal(
|
||||
hash_util.by_conversation_and_time_uri(message),
|
||||
hash_util.by_conversation_and_time_url(message),
|
||||
"http://zulip.zulipdev.com/#narrow/stream/99-frontend/topic/testing/near/42",
|
||||
);
|
||||
|
||||
|
@ -161,7 +161,7 @@ run_test("test_by_conversation_and_time_uri", () => {
|
|||
};
|
||||
|
||||
assert.equal(
|
||||
hash_util.by_conversation_and_time_uri(message),
|
||||
hash_util.by_conversation_and_time_url(message),
|
||||
"http://zulip.zulipdev.com/#narrow/pm-with/15-pm/near/43",
|
||||
);
|
||||
});
|
||||
|
|
|
@ -39,14 +39,14 @@ run_test("test encode_stream_id", () => {
|
|||
assert.equal(result, "123-stream-.28with-brackets.29");
|
||||
});
|
||||
|
||||
run_test("test by_stream_uri", () => {
|
||||
run_test("test by_stream_url", () => {
|
||||
const maybe_get_stream_name = () => "a test stream";
|
||||
const result = internal_url.by_stream_uri(123, maybe_get_stream_name);
|
||||
const result = internal_url.by_stream_url(123, maybe_get_stream_name);
|
||||
assert.equal(result, "#narrow/stream/123-a-test-stream");
|
||||
});
|
||||
|
||||
run_test("test by_stream_topic_uri", () => {
|
||||
run_test("test by_stream_topic_url", () => {
|
||||
const maybe_get_stream_name = () => "a test stream";
|
||||
const result = internal_url.by_stream_topic_uri(123, "test topic", maybe_get_stream_name);
|
||||
const result = internal_url.by_stream_topic_url(123, "test topic", maybe_get_stream_name);
|
||||
assert.equal(result, "#narrow/stream/123-a-test-stream/topic/test.20topic");
|
||||
});
|
||||
|
|
|
@ -171,14 +171,14 @@ run_test("uris", () => {
|
|||
people.add_active_user(me);
|
||||
people.initialize_current_user(me.user_id);
|
||||
|
||||
let uri = hash_util.pm_with_uri(ray.email);
|
||||
assert.equal(uri, "#narrow/pm-with/22-ray");
|
||||
let url = hash_util.pm_with_url(ray.email);
|
||||
assert.equal(url, "#narrow/pm-with/22-ray");
|
||||
|
||||
uri = hash_util.huddle_with_uri("22,23");
|
||||
assert.equal(uri, "#narrow/pm-with/22,23-group");
|
||||
url = hash_util.huddle_with_url("22,23");
|
||||
assert.equal(url, "#narrow/pm-with/22,23-group");
|
||||
|
||||
uri = hash_util.by_sender_uri(ray.email);
|
||||
assert.equal(uri, "#narrow/sender/22-ray");
|
||||
url = hash_util.by_sender_url(ray.email);
|
||||
assert.equal(url, "#narrow/sender/22-ray");
|
||||
|
||||
let emails = hash_util.decode_operand("pm-with", "22,23-group");
|
||||
assert.equal(emails, "alice@example.com,ray@example.com");
|
||||
|
|
|
@ -182,7 +182,7 @@ test_ui("sender_hover", ({override, mock_template}) => {
|
|||
user_circle_class: "user_circle_empty",
|
||||
user_last_seen_time_status:
|
||||
"translated: Last active: translated: More than 2 weeks ago",
|
||||
pm_with_uri: "#narrow/pm-with/42-alice",
|
||||
pm_with_url: "#narrow/pm-with/42-alice",
|
||||
sent_by_uri: "#narrow/sender/42-alice",
|
||||
private_message_class: "respond_personal_button",
|
||||
show_email: false,
|
||||
|
|
|
@ -76,9 +76,9 @@ mock_esm("../../static/js/compose_closed_ui", {
|
|||
update_buttons_for_recent_topics: noop,
|
||||
});
|
||||
mock_esm("../../static/js/hash_util", {
|
||||
by_stream_uri: () => "https://www.example.com",
|
||||
by_stream_url: () => "https://www.example.com",
|
||||
|
||||
by_stream_topic_uri: () => "https://www.example.com",
|
||||
by_stream_topic_url: () => "https://www.example.com",
|
||||
});
|
||||
mock_esm("../../static/js/message_list_data", {
|
||||
MessageListData: class {},
|
||||
|
|
|
@ -14,7 +14,7 @@ const ui = mock_esm("../../static/js/ui", {
|
|||
});
|
||||
|
||||
mock_esm("../../static/js/hash_util", {
|
||||
by_stream_uri: () => {},
|
||||
by_stream_url: () => {},
|
||||
get_current_hash_section: () => denmark_stream_id,
|
||||
});
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ export function info_for(user_id) {
|
|||
const user_circle_status = status_description(user_id);
|
||||
|
||||
return {
|
||||
href: hash_util.pm_with_uri(person.email),
|
||||
href: hash_util.pm_with_url(person.email),
|
||||
name: person.full_name,
|
||||
user_id,
|
||||
my_user_status,
|
||||
|
|
|
@ -244,7 +244,7 @@ export function initialize() {
|
|||
// so we re-encode the hash.
|
||||
const stream_id = Number.parseInt($(this).attr("data-stream-id"), 10);
|
||||
if (stream_id) {
|
||||
browser_history.go_to_location(hash_util.by_stream_uri(stream_id));
|
||||
browser_history.go_to_location(hash_util.by_stream_url(stream_id));
|
||||
return;
|
||||
}
|
||||
window.location.href = $(this).attr("href");
|
||||
|
|
|
@ -507,7 +507,7 @@ export function quote_and_reply(opts) {
|
|||
{defaultMessage: "{username} [said]({link_to_message}):"},
|
||||
{
|
||||
username: `@_**${message.sender_full_name}|${message.sender_id}**`,
|
||||
link_to_message: `${hash_util.by_conversation_and_time_uri(message)}`,
|
||||
link_to_message: `${hash_util.by_conversation_and_time_url(message)}`,
|
||||
},
|
||||
);
|
||||
content += "\n";
|
||||
|
|
|
@ -76,14 +76,14 @@ export function decode_operand(operator, operand) {
|
|||
return operand;
|
||||
}
|
||||
|
||||
export function by_stream_uri(stream_id) {
|
||||
// Wrapper for web use of internal_url.by_stream_uri
|
||||
return internal_url.by_stream_uri(stream_id, stream_data.maybe_get_stream_name);
|
||||
export function by_stream_url(stream_id) {
|
||||
// Wrapper for web use of internal_url.by_stream_url
|
||||
return internal_url.by_stream_url(stream_id, stream_data.maybe_get_stream_name);
|
||||
}
|
||||
|
||||
export function by_stream_topic_uri(stream_id, topic) {
|
||||
// Wrapper for web use of internal_url.by_stream_topic_uri
|
||||
return internal_url.by_stream_topic_uri(stream_id, topic, stream_data.maybe_get_stream_name);
|
||||
export function by_stream_topic_url(stream_id, topic) {
|
||||
// Wrapper for web use of internal_url.by_stream_topic_url
|
||||
return internal_url.by_stream_topic_url(stream_id, topic, stream_data.maybe_get_stream_name);
|
||||
}
|
||||
|
||||
// Encodes an operator list into the
|
||||
|
@ -113,16 +113,16 @@ export function operators_to_hash(operators) {
|
|||
return hash;
|
||||
}
|
||||
|
||||
export function by_sender_uri(reply_to) {
|
||||
export function by_sender_url(reply_to) {
|
||||
return operators_to_hash([{operator: "sender", operand: reply_to}]);
|
||||
}
|
||||
|
||||
export function pm_with_uri(reply_to) {
|
||||
export function pm_with_url(reply_to) {
|
||||
const slug = people.emails_to_slug(reply_to);
|
||||
return "#narrow/pm-with/" + slug;
|
||||
}
|
||||
|
||||
export function huddle_with_uri(user_ids_string) {
|
||||
export function huddle_with_url(user_ids_string) {
|
||||
// This method is convenient for callers
|
||||
// that have already converted emails to a comma-delimited
|
||||
// list of user_ids. We should be careful to keep this
|
||||
|
@ -130,7 +130,7 @@ export function huddle_with_uri(user_ids_string) {
|
|||
return "#narrow/pm-with/" + user_ids_string + "-group";
|
||||
}
|
||||
|
||||
export function by_conversation_and_time_uri(message) {
|
||||
export function by_conversation_and_time_url(message) {
|
||||
const absolute_url =
|
||||
window.location.protocol +
|
||||
"//" +
|
||||
|
@ -141,13 +141,13 @@ export function by_conversation_and_time_uri(message) {
|
|||
const suffix = "/near/" + internal_url.encodeHashComponent(message.id);
|
||||
|
||||
if (message.type === "stream") {
|
||||
return absolute_url + by_stream_topic_uri(message.stream_id, message.topic) + suffix;
|
||||
return absolute_url + by_stream_topic_url(message.stream_id, message.topic) + suffix;
|
||||
}
|
||||
|
||||
return absolute_url + people.pm_perma_link(message) + suffix;
|
||||
}
|
||||
|
||||
export function stream_edit_uri(sub) {
|
||||
export function stream_edit_url(sub) {
|
||||
const hash = `#streams/${sub.stream_id}/${internal_url.encodeHashComponent(sub.name)}`;
|
||||
return hash;
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ export const get_helpers = () => ({
|
|||
|
||||
// stream hashes
|
||||
get_stream_by_name: stream_data.get_sub,
|
||||
stream_hash: hash_util.by_stream_uri,
|
||||
stream_topic_hash: hash_util.by_stream_topic_uri,
|
||||
stream_hash: hash_util.by_stream_url,
|
||||
stream_topic_hash: hash_util.by_stream_topic_url,
|
||||
|
||||
// settings
|
||||
should_translate_emoticons: () => user_settings.translate_emoticons,
|
||||
|
|
|
@ -399,10 +399,10 @@ export class MessageListView {
|
|||
}
|
||||
|
||||
if (message_container.msg.stream) {
|
||||
message_container.stream_url = hash_util.by_stream_uri(
|
||||
message_container.stream_url = hash_util.by_stream_url(
|
||||
message_container.msg.stream_id,
|
||||
);
|
||||
message_container.topic_url = hash_util.by_stream_topic_uri(
|
||||
message_container.topic_url = hash_util.by_stream_topic_url(
|
||||
message_container.msg.stream_id,
|
||||
message_container.msg.topic,
|
||||
);
|
||||
|
@ -672,7 +672,7 @@ export class MessageListView {
|
|||
message.starred_status = $t({defaultMessage: "Star"});
|
||||
}
|
||||
|
||||
message.url = hash_util.by_conversation_and_time_uri(message);
|
||||
message.url = hash_util.by_conversation_and_time_url(message);
|
||||
|
||||
return {msg: message};
|
||||
});
|
||||
|
|
|
@ -652,7 +652,7 @@ export function notify_local_mixes(messages, need_user_to_scroll) {
|
|||
function get_above_composebox_narrow_url(message) {
|
||||
let above_composebox_narrow_url;
|
||||
if (message.type === "stream") {
|
||||
above_composebox_narrow_url = hash_util.by_stream_topic_uri(
|
||||
above_composebox_narrow_url = hash_util.by_stream_topic_url(
|
||||
message.stream_id,
|
||||
message.topic,
|
||||
);
|
||||
|
|
|
@ -97,7 +97,7 @@ export function _get_convos() {
|
|||
unread: num_unread,
|
||||
is_zero: num_unread === 0,
|
||||
is_active,
|
||||
url: hash_util.pm_with_uri(reply_to),
|
||||
url: hash_util.pm_with_url(reply_to),
|
||||
status_emoji_info,
|
||||
user_circle_class,
|
||||
is_group,
|
||||
|
|
|
@ -225,10 +225,10 @@ function render_user_info_popover(
|
|||
is_bot: user.is_bot,
|
||||
is_me,
|
||||
is_sender_popover,
|
||||
pm_with_uri: hash_util.pm_with_uri(user.email),
|
||||
pm_with_url: hash_util.pm_with_url(user.email),
|
||||
user_circle_class: buddy_data.get_user_circle_class(user.user_id),
|
||||
private_message_class: private_msg_class,
|
||||
sent_by_uri: hash_util.by_sender_uri(user.email),
|
||||
sent_by_uri: hash_util.by_sender_url(user.email),
|
||||
show_email: settings_data.show_email(),
|
||||
show_user_profile: !user.is_bot,
|
||||
user_email: people.get_visible_email(user),
|
||||
|
@ -504,7 +504,7 @@ export function toggle_actions_popover(element, id) {
|
|||
const should_display_quote_and_reply =
|
||||
message.content !== "<p>(deleted)</p>" && not_spectator;
|
||||
|
||||
const conversation_time_uri = hash_util.by_conversation_and_time_uri(message);
|
||||
const conversation_time_uri = hash_util.by_conversation_and_time_url(message);
|
||||
|
||||
const should_display_delete_option =
|
||||
message_edit.get_deletability(message) && not_spectator;
|
||||
|
|
|
@ -303,13 +303,13 @@ function format_topic(topic_data) {
|
|||
stream_color: stream_info.color,
|
||||
invite_only: stream_info.invite_only,
|
||||
is_web_public: stream_info.is_web_public,
|
||||
stream_url: hash_util.by_stream_uri(stream_id),
|
||||
stream_url: hash_util.by_stream_url(stream_id),
|
||||
|
||||
topic,
|
||||
topic_key: get_topic_key(stream_id, topic),
|
||||
unread_count,
|
||||
last_msg_time,
|
||||
topic_url: hash_util.by_stream_topic_uri(stream_id, topic),
|
||||
topic_url: hash_util.by_stream_topic_url(stream_id, topic),
|
||||
senders: senders_info,
|
||||
other_senders_count: Math.max(0, all_senders.length - MAX_AVATAR),
|
||||
other_sender_names_html,
|
||||
|
|
|
@ -137,7 +137,7 @@ export function do_set_reminder_for_message(message_id, timestamp) {
|
|||
return;
|
||||
}
|
||||
|
||||
const link_to_msg = hash_util.by_conversation_and_time_uri(message);
|
||||
const link_to_msg = hash_util.by_conversation_and_time_url(message);
|
||||
const reminder_msg_content =
|
||||
message.raw_content + "\n\n[Link to conversation](" + link_to_msg + ")";
|
||||
let reminder_message = {
|
||||
|
|
|
@ -35,7 +35,7 @@ export let toggler;
|
|||
export let select_tab = "personal_settings";
|
||||
|
||||
function setup_subscriptions_stream_hash(sub) {
|
||||
const hash = hash_util.stream_edit_uri(sub);
|
||||
const hash = hash_util.stream_edit_url(sub);
|
||||
browser_history.update(hash);
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ function build_stream_sidebar_li(sub) {
|
|||
const args = {
|
||||
name,
|
||||
id: sub.stream_id,
|
||||
uri: hash_util.by_stream_uri(sub.stream_id),
|
||||
uri: hash_util.by_stream_url(sub.stream_id),
|
||||
is_muted: stream_data.is_muted(sub.stream_id) === true,
|
||||
invite_only: sub.invite_only,
|
||||
is_web_public: sub.is_web_public,
|
||||
|
|
|
@ -567,7 +567,7 @@ export function register_stream_handlers() {
|
|||
const sub = stream_popover_sub(e);
|
||||
hide_stream_popover();
|
||||
|
||||
const stream_edit_hash = hash_util.stream_edit_uri(sub);
|
||||
const stream_edit_hash = hash_util.stream_edit_url(sub);
|
||||
browser_history.go_to_location(stream_edit_hash);
|
||||
});
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ export function add_settings_fields(sub) {
|
|||
sub.can_access_subscribers = stream_data.can_view_subscribers(sub);
|
||||
sub.can_add_subscribers = stream_data.can_subscribe_others(sub);
|
||||
|
||||
sub.preview_url = hash_util.by_stream_uri(sub.stream_id);
|
||||
sub.preview_url = hash_util.by_stream_url(sub.stream_id);
|
||||
sub.is_old_stream = sub.stream_weekly_traffic !== null;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ export function get_list_info(stream_id, zoomed) {
|
|||
is_zero: num_unread === 0,
|
||||
is_muted: is_topic_muted,
|
||||
is_active_topic,
|
||||
url: hash_util.by_stream_topic_uri(stream_id, topic_name),
|
||||
url: hash_util.by_stream_topic_url(stream_id, topic_name),
|
||||
resolved,
|
||||
resolved_topic_prefix: message_edit.RESOLVED_TOPIC_PREFIX,
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ function format_user_stream_list_item(stream, user) {
|
|||
is_web_public: stream.is_web_public,
|
||||
show_unsubscribe_button,
|
||||
show_private_stream_unsub_tooltip,
|
||||
stream_edit_url: hash_util.stream_edit_uri(stream),
|
||||
stream_edit_url: hash_util.stream_edit_url(stream),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ export function register_click_handlers() {
|
|||
}
|
||||
|
||||
if (sub.invite_only && people.is_my_user_id(target_user_id)) {
|
||||
const new_hash = hash_util.stream_edit_uri(sub);
|
||||
const new_hash = hash_util.stream_edit_url(sub);
|
||||
hide_user_profile();
|
||||
browser_history.go_to_location(new_hash);
|
||||
return;
|
||||
|
|
|
@ -39,11 +39,11 @@ export function encode_stream_id(stream_id, maybe_get_stream_name) {
|
|||
return encodeHashComponent(slug);
|
||||
}
|
||||
|
||||
export function by_stream_uri(stream_id, maybe_get_stream_name) {
|
||||
export function by_stream_url(stream_id, maybe_get_stream_name) {
|
||||
return "#narrow/stream/" + encode_stream_id(stream_id, maybe_get_stream_name);
|
||||
}
|
||||
|
||||
export function by_stream_topic_uri(stream_id, topic, maybe_get_stream_name) {
|
||||
export function by_stream_topic_url(stream_id, topic, maybe_get_stream_name) {
|
||||
return (
|
||||
"#narrow/stream/" +
|
||||
encode_stream_id(stream_id, maybe_get_stream_name) +
|
||||
|
|
|
@ -151,7 +151,7 @@
|
|||
{{/if}}
|
||||
<hr />
|
||||
<li>
|
||||
<a href="{{ pm_with_uri }}" class="narrow_to_private_messages">
|
||||
<a href="{{ pm_with_url }}" class="narrow_to_private_messages">
|
||||
<i class="fa fa-lock" aria-hidden="true"></i>
|
||||
{{#if is_me}}
|
||||
{{#tr}}View private messages to myself{{/tr}}
|
||||
|
|
Loading…
Reference in New Issue