From 02364dd69f37298fc7f6cf5f478454ca58d94fff Mon Sep 17 00:00:00 2001 From: AcKindle3 Date: Sat, 8 Apr 2023 23:22:23 -0400 Subject: [PATCH] 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. --- stylelint.config.js | 2 +- web/src/filter.js | 2 +- web/src/gear_menu.ts | 2 +- web/src/people.js | 8 ++++---- web/src/popover_menus_data.js | 4 ++-- web/src/popovers.js | 2 +- web/src/settings_account.js | 2 +- web/src/settings_bots.js | 8 ++++---- web/src/settings_users.js | 4 ++-- web/src/stream_list.js | 2 +- web/src/upload.js | 12 ++++++------ web/src/util.ts | 2 +- web/templates/actions_popover_content.hbs | 2 +- .../confirm_dialog/confirm_deactivate_user.hbs | 2 +- web/templates/gear_menu.hbs | 2 +- web/templates/stream_sidebar_row.hbs | 2 +- web/templates/user_info_popover_content.hbs | 2 +- web/tests/hash_util.test.js | 4 ++-- web/tests/i18n.test.js | 2 +- web/tests/people_errors.test.js | 4 ++-- web/tests/popovers.test.js | 2 +- web/tests/settings_bots.test.js | 6 +++--- web/tests/stream_list.test.js | 6 +++--- web/tests/util.test.js | 8 ++++---- 24 files changed, 46 insertions(+), 46 deletions(-) diff --git a/stylelint.config.js b/stylelint.config.js index e8c5cf7bde..53feeb8810 100644 --- a/stylelint.config.js +++ b/stylelint.config.js @@ -37,7 +37,7 @@ module.exports = { // Zulip CSS should have no dependencies on external resources "function-url-no-scheme-relative": true, "function-url-scheme-allowed-list": [ - "data", // Allow data URIs + "data", // Allow data URLs ], }, }; diff --git a/web/src/filter.js b/web/src/filter.js index a33a7fb7c5..ec6dbc2dcc 100644 --- a/web/src/filter.js +++ b/web/src/filter.js @@ -285,7 +285,7 @@ export class Filter { if (["group-pm-with", "pm-with", "sender", "from"].includes(operator) === false) { 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). diff --git a/web/src/gear_menu.ts b/web/src/gear_menu.ts index 7d3203989f..b5b4ce479c 100644 --- a/web/src/gear_menu.ts +++ b/web/src/gear_menu.ts @@ -113,7 +113,7 @@ export function version_display_string(): string { export function initialize(): void { const rendered_gear_menu = render_gear_menu({ 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_admin: page_params.is_admin, is_self_hosted: page_params.realm_plan_type === 1, diff --git a/web/src/people.js b/web/src/people.js index a02b7fd91a..d275cec25b 100644 --- a/web/src/people.js +++ b/web/src/people.js @@ -534,8 +534,8 @@ export function pm_perma_link(message) { } const slug = user_ids.join(",") + "-" + suffix; - const uri = "#narrow/pm-with/" + slug; - return uri; + const url = "#narrow/pm-with/" + slug; + return url; } export function pm_with_url(message) { @@ -560,8 +560,8 @@ export function pm_with_url(message) { } const slug = user_ids.join(",") + "-" + suffix; - const uri = "#narrow/pm-with/" + slug; - return uri; + const url = "#narrow/pm-with/" + slug; + return url; } export function update_email_in_reply_to(reply_to, user_id, new_email) { diff --git a/web/src/popover_menus_data.js b/web/src/popover_menus_data.js index 62b1c97a40..cb4b9a4bf9 100644 --- a/web/src/popover_menus_data.js +++ b/web/src/popover_menus_data.js @@ -87,7 +87,7 @@ export function get_actions_popover_content_context(message_id) { const should_display_quote_and_reply = message.content !== "

(deleted)

" && 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_read_receipts_option = @@ -116,7 +116,7 @@ export function get_actions_popover_content_context(message_id) { should_display_add_reaction_option, should_display_edit_history_option, should_display_hide_option, - conversation_time_uri, + conversation_time_url, narrowed: narrow_state.active(), should_display_delete_option, should_display_read_receipts_option, diff --git a/web/src/popovers.js b/web/src/popovers.js index 86142dcdfd..144bf035c0 100644 --- a/web/src/popovers.js +++ b/web/src/popovers.js @@ -275,7 +275,7 @@ function render_user_info_popover( 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_url(user.email), + sent_by_url: hash_util.by_sender_url(user.email), show_manage_menu, user_email: user.delivery_email, user_full_name: user.full_name, diff --git a/web/src/settings_account.js b/web/src/settings_account.js index 0366d23da1..b0f38d3f37 100644 --- a/web/src/settings_account.js +++ b/web/src/settings_account.js @@ -498,7 +498,7 @@ export function set_up() { api_key: $("#api_key_value").text(), }; 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", () => { diff --git a/web/src/settings_bots.js b/web/src/settings_bots.js index 5525569faa..f0a3f71fef 100644 --- a/web/src/settings_bots.js +++ b/web/src/settings_bots.js @@ -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 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); } @@ -596,7 +596,7 @@ export function set_up() { $("#active_bots_list").on("click", "a.download_bot_zuliprc", function () { const $bot_info = $(this).closest(".bot-information-box").find(".bot_info"); 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) => { diff --git a/web/src/settings_users.js b/web/src/settings_users.js index ee3906e284..ff98046dec 100644 --- a/web/src/settings_users.js +++ b/web/src/settings_users.js @@ -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 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 opts = { username: user.full_name, @@ -484,7 +484,7 @@ export function confirm_deactivation(user_id, handle_confirm, loading_spinner) { bots_owned_by_user, number_of_invites_by_user, admin_email: people.my_current_email(), - realm_uri, + realm_url, realm_name, }; const html_body = render_settings_deactivation_user_modal(opts); diff --git a/web/src/stream_list.js b/web/src/stream_list.js index b0a183c254..1719fbf2bb 100644 --- a/web/src/stream_list.js +++ b/web/src/stream_list.js @@ -318,7 +318,7 @@ function build_stream_sidebar_li(sub) { const args = { name, 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, invite_only: sub.invite_only, is_web_public: sub.is_web_public, diff --git a/web/src/upload.js b/web/src/upload.js index 8fef92e3c5..b3077532e0 100644 --- a/web/src/upload.js +++ b/web/src/upload.js @@ -281,19 +281,19 @@ export function setup_upload(config) { }); uppy.on("upload-success", (file, response) => { - const uri = response.body.uri; - if (uri === undefined) { + const url = response.body.uri; + if (url === undefined) { return; } - const split_uri = uri.split("/"); - const filename = split_uri.at(-1); + const split_url = url.split("/"); + const filename = split_url.at(-1); if (config.mode === "compose" && !compose_state.composing()) { compose_actions.start("stream"); } - const filename_uri = "[" + filename + "](" + uri + ")"; + const filename_url = "[" + filename + "](" + url + ")"; compose_ui.replace_syntax( get_translated_status(file), - filename_uri, + filename_url, get_item("textarea", config), ); compose_ui.autosize_textarea(get_item("textarea", config)); diff --git a/web/src/util.ts b/web/src/util.ts index 0f62aeaa27..e7ea6627f4 100644 --- a/web/src/util.ts +++ b/web/src/util.ts @@ -117,7 +117,7 @@ export function normalize_recipients(recipients: string): string { // one by one until the decode succeeds. This makes sense if // we are decoding input that the user is in the middle of // typing. -export function robust_uri_decode(str: string): string { +export function robust_url_decode(str: string): string { let end = str.length; while (end > 0) { try { diff --git a/web/templates/actions_popover_content.hbs b/web/templates/actions_popover_content.hbs index 257a1e9b09..7e22c1e1c7 100644 --- a/web/templates/actions_popover_content.hbs +++ b/web/templates/actions_popover_content.hbs @@ -127,7 +127,7 @@ {{/if}}
  • - + {{t "Copy link to message" }}
  • diff --git a/web/templates/confirm_dialog/confirm_deactivate_user.hbs b/web/templates/confirm_dialog/confirm_deactivate_user.hbs index b3217c9daa..30aee0c6a9 100644 --- a/web/templates/confirm_dialog/confirm_deactivate_user.hbs +++ b/web/templates/confirm_dialog/confirm_deactivate_user.hbs @@ -35,7 +35,7 @@ {{#tr}} Your Zulip account on has been deactivated, and you will no longer be able to log in. - {{#*inline "z-link"}}{{realm_uri}}{{/inline}} + {{#*inline "z-link"}}{{realm_url}}{{/inline}} {{/tr}}

    {{t "The administrators provided the following comment:" }}

    diff --git a/web/templates/gear_menu.hbs b/web/templates/gear_menu.hbs index dd8c19e78d..7199a97d38 100644 --- a/web/templates/gear_menu.hbs +++ b/web/templates/gear_menu.hbs @@ -5,7 +5,7 @@