web: Use `uri` instead of `url`.

Following the issue #23380 and PR #25038, this commit changes all
occurences of `uri` into `url` in all comments, local variables,
handlebars templates (.hbs) function names and their callers in
all `.js` and `.ts` files.
This commit is contained in:
AcKindle3 2023-04-08 23:22:23 -04:00 committed by Tim Abbott
parent 5a89d3b4d2
commit 02364dd69f
24 changed files with 46 additions and 46 deletions

View File

@ -37,7 +37,7 @@ module.exports = {
// Zulip CSS should have no dependencies on external resources // Zulip CSS should have no dependencies on external resources
"function-url-no-scheme-relative": true, "function-url-no-scheme-relative": true,
"function-url-scheme-allowed-list": [ "function-url-scheme-allowed-list": [
"data", // Allow data URIs "data", // Allow data URLs
], ],
}, },
}; };

View File

@ -285,7 +285,7 @@ export class Filter {
if (["group-pm-with", "pm-with", "sender", "from"].includes(operator) === false) { if (["group-pm-with", "pm-with", "sender", "from"].includes(operator) === false) {
encoded = encoded.replace(/\+/g, " "); encoded = encoded.replace(/\+/g, " ");
} }
return util.robust_uri_decode(encoded).trim(); return util.robust_url_decode(encoded).trim();
} }
// Parse a string into a list of operators (see below). // Parse a string into a list of operators (see below).

View File

@ -113,7 +113,7 @@ export function version_display_string(): string {
export function initialize(): void { export function initialize(): void {
const rendered_gear_menu = render_gear_menu({ const rendered_gear_menu = render_gear_menu({
realm_name: page_params.realm_name, realm_name: page_params.realm_name,
realm_uri: new URL(page_params.realm_uri).hostname, realm_url: new URL(page_params.realm_uri).hostname,
is_owner: page_params.is_owner, is_owner: page_params.is_owner,
is_admin: page_params.is_admin, is_admin: page_params.is_admin,
is_self_hosted: page_params.realm_plan_type === 1, is_self_hosted: page_params.realm_plan_type === 1,

View File

@ -534,8 +534,8 @@ export function pm_perma_link(message) {
} }
const slug = user_ids.join(",") + "-" + suffix; const slug = user_ids.join(",") + "-" + suffix;
const uri = "#narrow/pm-with/" + slug; const url = "#narrow/pm-with/" + slug;
return uri; return url;
} }
export function pm_with_url(message) { export function pm_with_url(message) {
@ -560,8 +560,8 @@ export function pm_with_url(message) {
} }
const slug = user_ids.join(",") + "-" + suffix; const slug = user_ids.join(",") + "-" + suffix;
const uri = "#narrow/pm-with/" + slug; const url = "#narrow/pm-with/" + slug;
return uri; return url;
} }
export function update_email_in_reply_to(reply_to, user_id, new_email) { export function update_email_in_reply_to(reply_to, user_id, new_email) {

View File

@ -87,7 +87,7 @@ export function get_actions_popover_content_context(message_id) {
const should_display_quote_and_reply = message.content !== "<p>(deleted)</p>" && not_spectator; const should_display_quote_and_reply = message.content !== "<p>(deleted)</p>" && not_spectator;
const conversation_time_uri = hash_util.by_conversation_and_time_url(message); const conversation_time_url = hash_util.by_conversation_and_time_url(message);
const should_display_delete_option = message_edit.get_deletability(message) && not_spectator; const should_display_delete_option = message_edit.get_deletability(message) && not_spectator;
const should_display_read_receipts_option = const should_display_read_receipts_option =
@ -116,7 +116,7 @@ export function get_actions_popover_content_context(message_id) {
should_display_add_reaction_option, should_display_add_reaction_option,
should_display_edit_history_option, should_display_edit_history_option,
should_display_hide_option, should_display_hide_option,
conversation_time_uri, conversation_time_url,
narrowed: narrow_state.active(), narrowed: narrow_state.active(),
should_display_delete_option, should_display_delete_option,
should_display_read_receipts_option, should_display_read_receipts_option,

View File

@ -275,7 +275,7 @@ function render_user_info_popover(
pm_with_url: hash_util.pm_with_url(user.email), pm_with_url: hash_util.pm_with_url(user.email),
user_circle_class: buddy_data.get_user_circle_class(user.user_id), user_circle_class: buddy_data.get_user_circle_class(user.user_id),
private_message_class: private_msg_class, private_message_class: private_msg_class,
sent_by_uri: hash_util.by_sender_url(user.email), sent_by_url: hash_util.by_sender_url(user.email),
show_manage_menu, show_manage_menu,
user_email: user.delivery_email, user_email: user.delivery_email,
user_full_name: user.full_name, user_full_name: user.full_name,

View File

@ -498,7 +498,7 @@ export function set_up() {
api_key: $("#api_key_value").text(), api_key: $("#api_key_value").text(),
}; };
const data = settings_bots.generate_zuliprc_content(bot_object); const data = settings_bots.generate_zuliprc_content(bot_object);
$(this).attr("href", settings_bots.encode_zuliprc_as_uri(data)); $(this).attr("href", settings_bots.encode_zuliprc_as_url(data));
}); });
$("#api_key_modal [data-micromodal-close]").on("click", () => { $("#api_key_modal [data-micromodal-close]").on("click", () => {

View File

@ -82,13 +82,13 @@ export function render_bots() {
} }
} }
export function generate_zuliprc_uri(bot_id) { export function generate_zuliprc_url(bot_id) {
const bot = bot_data.get(bot_id); const bot = bot_data.get(bot_id);
const data = generate_zuliprc_content(bot); const data = generate_zuliprc_content(bot);
return encode_zuliprc_as_uri(data); return encode_zuliprc_as_url(data);
} }
export function encode_zuliprc_as_uri(zuliprc) { export function encode_zuliprc_as_url(zuliprc) {
return "data:application/octet-stream;charset=utf-8," + encodeURIComponent(zuliprc); return "data:application/octet-stream;charset=utf-8," + encodeURIComponent(zuliprc);
} }
@ -596,7 +596,7 @@ export function set_up() {
$("#active_bots_list").on("click", "a.download_bot_zuliprc", function () { $("#active_bots_list").on("click", "a.download_bot_zuliprc", function () {
const $bot_info = $(this).closest(".bot-information-box").find(".bot_info"); const $bot_info = $(this).closest(".bot-information-box").find(".bot_info");
const bot_id = Number.parseInt($bot_info.attr("data-user-id"), 10); const bot_id = Number.parseInt($bot_info.attr("data-user-id"), 10);
$(this).attr("href", generate_zuliprc_uri(bot_id)); $(this).attr("href", generate_zuliprc_url(bot_id));
}); });
$("#active_bots_list").on("click", "button.open_bots_subscribed_streams", (e) => { $("#active_bots_list").on("click", "button.open_bots_subscribed_streams", (e) => {

View File

@ -476,7 +476,7 @@ export function confirm_deactivation(user_id, handle_confirm, loading_spinner) {
const bots_owned_by_user = bot_data.get_all_bots_owned_by_user(user_id); const bots_owned_by_user = bot_data.get_all_bots_owned_by_user(user_id);
const user = people.get_by_user_id(user_id); const user = people.get_by_user_id(user_id);
const realm_uri = page_params.realm_uri; const realm_url = page_params.realm_uri;
const realm_name = page_params.realm_name; const realm_name = page_params.realm_name;
const opts = { const opts = {
username: user.full_name, username: user.full_name,
@ -484,7 +484,7 @@ export function confirm_deactivation(user_id, handle_confirm, loading_spinner) {
bots_owned_by_user, bots_owned_by_user,
number_of_invites_by_user, number_of_invites_by_user,
admin_email: people.my_current_email(), admin_email: people.my_current_email(),
realm_uri, realm_url,
realm_name, realm_name,
}; };
const html_body = render_settings_deactivation_user_modal(opts); const html_body = render_settings_deactivation_user_modal(opts);

View File

@ -318,7 +318,7 @@ function build_stream_sidebar_li(sub) {
const args = { const args = {
name, name,
id: sub.stream_id, id: sub.stream_id,
uri: hash_util.by_stream_url(sub.stream_id), url: hash_util.by_stream_url(sub.stream_id),
is_muted: stream_data.is_muted(sub.stream_id) === true, is_muted: stream_data.is_muted(sub.stream_id) === true,
invite_only: sub.invite_only, invite_only: sub.invite_only,
is_web_public: sub.is_web_public, is_web_public: sub.is_web_public,

View File

@ -281,19 +281,19 @@ export function setup_upload(config) {
}); });
uppy.on("upload-success", (file, response) => { uppy.on("upload-success", (file, response) => {
const uri = response.body.uri; const url = response.body.uri;
if (uri === undefined) { if (url === undefined) {
return; return;
} }
const split_uri = uri.split("/"); const split_url = url.split("/");
const filename = split_uri.at(-1); const filename = split_url.at(-1);
if (config.mode === "compose" && !compose_state.composing()) { if (config.mode === "compose" && !compose_state.composing()) {
compose_actions.start("stream"); compose_actions.start("stream");
} }
const filename_uri = "[" + filename + "](" + uri + ")"; const filename_url = "[" + filename + "](" + url + ")";
compose_ui.replace_syntax( compose_ui.replace_syntax(
get_translated_status(file), get_translated_status(file),
filename_uri, filename_url,
get_item("textarea", config), get_item("textarea", config),
); );
compose_ui.autosize_textarea(get_item("textarea", config)); compose_ui.autosize_textarea(get_item("textarea", config));

View File

@ -117,7 +117,7 @@ export function normalize_recipients(recipients: string): string {
// one by one until the decode succeeds. This makes sense if // one by one until the decode succeeds. This makes sense if
// we are decoding input that the user is in the middle of // we are decoding input that the user is in the middle of
// typing. // typing.
export function robust_uri_decode(str: string): string { export function robust_url_decode(str: string): string {
let end = str.length; let end = str.length;
while (end > 0) { while (end > 0) {
try { try {

View File

@ -127,7 +127,7 @@
{{/if}} {{/if}}
<li> <li>
<a class="copy_link" data-message-id="{{message_id}}" data-clipboard-text="{{ conversation_time_uri }}" tabindex="0"> <a class="copy_link" data-message-id="{{message_id}}" data-clipboard-text="{{ conversation_time_url }}" tabindex="0">
<i class="fa fa-link" aria-hidden="true"></i> {{t "Copy link to message" }} <i class="fa fa-link" aria-hidden="true"></i> {{t "Copy link to message" }}
</a> </a>
</li> </li>

View File

@ -35,7 +35,7 @@
{{#tr}} {{#tr}}
Your Zulip account on <z-link></z-link> has been deactivated, Your Zulip account on <z-link></z-link> has been deactivated,
and you will no longer be able to log in. and you will no longer be able to log in.
{{#*inline "z-link"}}<a href="{{realm_uri}}">{{realm_uri}}</a>{{/inline}} {{#*inline "z-link"}}<a href="{{realm_url}}">{{realm_url}}</a>{{/inline}}
{{/tr}} {{/tr}}
</p> </p>
<p>{{t "The administrators provided the following comment:" }}</p> <p>{{t "The administrators provided the following comment:" }}</p>

View File

@ -5,7 +5,7 @@
</a> </a>
<ul class="dropdown-menu" role="menu" aria-labelledby="settings-dropdown"> <ul class="dropdown-menu" role="menu" aria-labelledby="settings-dropdown">
<li class="org-info org-name">{{realm_name}}</li> <li class="org-info org-name">{{realm_name}}</li>
<li class="org-info org-url">{{realm_uri}}</li> <li class="org-info org-url">{{realm_url}}</li>
{{#if is_self_hosted }} {{#if is_self_hosted }}
<li class="org-info org-version"> <li class="org-info org-version">
<a href="#about-zulip" role="menuitem">{{version_display_string}}</a> <a href="#about-zulip" role="menuitem">{{version_display_string}}</a>

View File

@ -8,7 +8,7 @@
{{> stream_privacy }} {{> stream_privacy }}
</span> </span>
<a href="{{uri}}" title="{{name}}" class="stream-name">{{name}}</a> <a href="{{url}}" title="{{name}}" class="stream-name">{{name}}</a>
<span class="unread_mention_info"></span> <span class="unread_mention_info"></span>
<span class="unread_count"></span> <span class="unread_count"></span>

View File

@ -164,7 +164,7 @@
</a> </a>
</li> </li>
<li> <li>
<a href="{{ sent_by_uri }}" class="narrow_to_messages_sent"> <a href="{{ sent_by_url }}" class="narrow_to_messages_sent">
<i class="fa fa-paper-plane" aria-hidden="true"></i> {{t "View messages sent" }} <i class="fa fa-paper-plane" aria-hidden="true"></i> {{t "View messages sent" }}
</a> </a>
</li> </li>

View File

@ -167,8 +167,8 @@ run_test("test_by_conversation_and_time_url", () => {
}); });
run_test("test_search_public_streams_notice_url", () => { run_test("test_search_public_streams_notice_url", () => {
function get_operators(uri) { function get_operators(url) {
return hash_util.parse_narrow(uri.split("/")); return hash_util.parse_narrow(url.split("/"));
} }
assert.equal( assert.equal(

View File

@ -73,7 +73,7 @@ run_test("t_tag", ({mock_template}) => {
should_display_quote_and_reply: true, should_display_quote_and_reply: true,
editability_menu_item: true, editability_menu_item: true,
should_display_hide_option: true, should_display_hide_option: true,
conversation_time_uri: conversation_time_url:
"http://zulip.zulipdev.com/#narrow/stream/101-devel/topic/testing/near/99", "http://zulip.zulipdev.com/#narrow/stream/101-devel/topic/testing/near/99",
}; };

View File

@ -106,8 +106,8 @@ run_test("blueslip", () => {
blueslip.expect("error", "Unknown user_id in get_by_user_id: 42"); blueslip.expect("error", "Unknown user_id in get_by_user_id: 42");
blueslip.expect("error", "Unknown people in message"); blueslip.expect("error", "Unknown people in message");
const uri = people.pm_with_url({type: "private", display_recipient: [{id: 42}]}); const url = people.pm_with_url({type: "private", display_recipient: [{id: 42}]});
assert.equal(uri.indexOf("unk"), uri.length - 3); assert.equal(url.indexOf("unk"), url.length - 3);
blueslip.expect("error", "Undefined field id"); blueslip.expect("error", "Undefined field id");
assert.equal(people.my_custom_profile_data(undefined), undefined); assert.equal(people.my_custom_profile_data(undefined), undefined);

View File

@ -177,7 +177,7 @@ test_ui("sender_hover", ({override, mock_template}) => {
user_circle_class: "user_circle_empty", user_circle_class: "user_circle_empty",
user_last_seen_time_status: "translated: Active more than 2 weeks ago", user_last_seen_time_status: "translated: Active more than 2 weeks ago",
pm_with_url: "#narrow/pm-with/42-Alice-Smith", pm_with_url: "#narrow/pm-with/42-Alice-Smith",
sent_by_uri: "#narrow/sender/42-Alice-Smith", sent_by_url: "#narrow/sender/42-Alice-Smith",
private_message_class: "respond_personal_button", private_message_class: "respond_personal_button",
show_manage_menu: true, show_manage_menu: true,
is_me: false, is_me: false,

View File

@ -42,8 +42,8 @@ function test(label, f) {
}); });
} }
test("generate_zuliprc_uri", () => { test("generate_zuliprc_url", () => {
const uri = settings_bots.generate_zuliprc_uri(1); const url = settings_bots.generate_zuliprc_url(1);
const expected = const expected =
"data:application/octet-stream;charset=utf-8," + "data:application/octet-stream;charset=utf-8," +
encodeURIComponent( encodeURIComponent(
@ -52,7 +52,7 @@ test("generate_zuliprc_uri", () => {
"site=https://chat.example.com\n", "site=https://chat.example.com\n",
); );
assert.equal(uri, expected); assert.equal(url, expected);
}); });
test("generate_zuliprc_content", () => { test("generate_zuliprc_content", () => {

View File

@ -70,7 +70,7 @@ function create_devel_sidebar_row({mock_template}) {
$subscription_block.set_find_results(".unread_mention_info", $devel_unread_mention_info); $subscription_block.set_find_results(".unread_mention_info", $devel_unread_mention_info);
mock_template("stream_sidebar_row.hbs", false, (data) => { mock_template("stream_sidebar_row.hbs", false, (data) => {
assert.equal(data.uri, "#narrow/stream/100-devel"); assert.equal(data.url, "#narrow/stream/100-devel");
return "<devel-sidebar-row-stub>"; return "<devel-sidebar-row-stub>";
}); });
@ -93,7 +93,7 @@ function create_social_sidebar_row({mock_template}) {
$subscription_block.set_find_results(".unread_mention_info", $social_unread_mention_info); $subscription_block.set_find_results(".unread_mention_info", $social_unread_mention_info);
mock_template("stream_sidebar_row.hbs", false, (data) => { mock_template("stream_sidebar_row.hbs", false, (data) => {
assert.equal(data.uri, "#narrow/stream/200-social"); assert.equal(data.url, "#narrow/stream/200-social");
return "<social-sidebar-row-stub>"; return "<social-sidebar-row-stub>";
}); });
@ -662,7 +662,7 @@ test_ui("rename_stream", ({mock_template}) => {
assert.deepEqual(payload, { assert.deepEqual(payload, {
name: "Development", name: "Development",
id: 1000, id: 1000,
uri: "#narrow/stream/1000-Development", url: "#narrow/stream/1000-Development",
is_muted: false, is_muted: false,
invite_only: undefined, invite_only: undefined,
is_web_public: undefined, is_web_public: undefined,

View File

@ -86,16 +86,16 @@ run_test("same_recipient", () => {
assert.ok(!util.same_recipient(undefined, undefined)); assert.ok(!util.same_recipient(undefined, undefined));
}); });
run_test("robust_uri_decode", ({override}) => { run_test("robust_url_decode", ({override}) => {
assert.equal(util.robust_uri_decode("xxx%3Ayyy"), "xxx:yyy"); assert.equal(util.robust_url_decode("xxx%3Ayyy"), "xxx:yyy");
assert.equal(util.robust_uri_decode("xxx%3"), "xxx"); assert.equal(util.robust_url_decode("xxx%3"), "xxx");
override(global, "decodeURIComponent", () => { override(global, "decodeURIComponent", () => {
throw new Error("foo"); throw new Error("foo");
}); });
assert.throws( assert.throws(
() => { () => {
util.robust_uri_decode("%E0%A4%A"); util.robust_url_decode("%E0%A4%A");
}, },
{name: "Error", message: "foo"}, {name: "Error", message: "foo"},
); );