mirror of https://github.com/zulip/zulip.git
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:
parent
5a89d3b4d2
commit
02364dd69f
|
@ -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
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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", () => {
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
{{/if}}
|
||||
|
||||
<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" }}
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
{{#tr}}
|
||||
Your Zulip account on <z-link></z-link> has been deactivated,
|
||||
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}}
|
||||
</p>
|
||||
<p>{{t "The administrators provided the following comment:" }}</p>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="settings-dropdown">
|
||||
<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 }}
|
||||
<li class="org-info org-version">
|
||||
<a href="#about-zulip" role="menuitem">{{version_display_string}}</a>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{{> stream_privacy }}
|
||||
</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_count"></span>
|
||||
|
|
|
@ -164,7 +164,7 @@
|
|||
</a>
|
||||
</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" }}
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -167,8 +167,8 @@ run_test("test_by_conversation_and_time_url", () => {
|
|||
});
|
||||
|
||||
run_test("test_search_public_streams_notice_url", () => {
|
||||
function get_operators(uri) {
|
||||
return hash_util.parse_narrow(uri.split("/"));
|
||||
function get_operators(url) {
|
||||
return hash_util.parse_narrow(url.split("/"));
|
||||
}
|
||||
|
||||
assert.equal(
|
||||
|
|
|
@ -73,7 +73,7 @@ run_test("t_tag", ({mock_template}) => {
|
|||
should_display_quote_and_reply: true,
|
||||
editability_menu_item: true,
|
||||
should_display_hide_option: true,
|
||||
conversation_time_uri:
|
||||
conversation_time_url:
|
||||
"http://zulip.zulipdev.com/#narrow/stream/101-devel/topic/testing/near/99",
|
||||
};
|
||||
|
||||
|
|
|
@ -106,8 +106,8 @@ run_test("blueslip", () => {
|
|||
|
||||
blueslip.expect("error", "Unknown user_id in get_by_user_id: 42");
|
||||
blueslip.expect("error", "Unknown people in message");
|
||||
const uri = people.pm_with_url({type: "private", display_recipient: [{id: 42}]});
|
||||
assert.equal(uri.indexOf("unk"), uri.length - 3);
|
||||
const url = people.pm_with_url({type: "private", display_recipient: [{id: 42}]});
|
||||
assert.equal(url.indexOf("unk"), url.length - 3);
|
||||
|
||||
blueslip.expect("error", "Undefined field id");
|
||||
assert.equal(people.my_custom_profile_data(undefined), undefined);
|
||||
|
|
|
@ -177,7 +177,7 @@ test_ui("sender_hover", ({override, mock_template}) => {
|
|||
user_circle_class: "user_circle_empty",
|
||||
user_last_seen_time_status: "translated: Active more than 2 weeks ago",
|
||||
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",
|
||||
show_manage_menu: true,
|
||||
is_me: false,
|
||||
|
|
|
@ -42,8 +42,8 @@ function test(label, f) {
|
|||
});
|
||||
}
|
||||
|
||||
test("generate_zuliprc_uri", () => {
|
||||
const uri = settings_bots.generate_zuliprc_uri(1);
|
||||
test("generate_zuliprc_url", () => {
|
||||
const url = settings_bots.generate_zuliprc_url(1);
|
||||
const expected =
|
||||
"data:application/octet-stream;charset=utf-8," +
|
||||
encodeURIComponent(
|
||||
|
@ -52,7 +52,7 @@ test("generate_zuliprc_uri", () => {
|
|||
"site=https://chat.example.com\n",
|
||||
);
|
||||
|
||||
assert.equal(uri, expected);
|
||||
assert.equal(url, expected);
|
||||
});
|
||||
|
||||
test("generate_zuliprc_content", () => {
|
||||
|
|
|
@ -70,7 +70,7 @@ function create_devel_sidebar_row({mock_template}) {
|
|||
$subscription_block.set_find_results(".unread_mention_info", $devel_unread_mention_info);
|
||||
|
||||
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>";
|
||||
});
|
||||
|
||||
|
@ -93,7 +93,7 @@ function create_social_sidebar_row({mock_template}) {
|
|||
$subscription_block.set_find_results(".unread_mention_info", $social_unread_mention_info);
|
||||
|
||||
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>";
|
||||
});
|
||||
|
||||
|
@ -662,7 +662,7 @@ test_ui("rename_stream", ({mock_template}) => {
|
|||
assert.deepEqual(payload, {
|
||||
name: "Development",
|
||||
id: 1000,
|
||||
uri: "#narrow/stream/1000-Development",
|
||||
url: "#narrow/stream/1000-Development",
|
||||
is_muted: false,
|
||||
invite_only: undefined,
|
||||
is_web_public: undefined,
|
||||
|
|
|
@ -86,16 +86,16 @@ run_test("same_recipient", () => {
|
|||
assert.ok(!util.same_recipient(undefined, undefined));
|
||||
});
|
||||
|
||||
run_test("robust_uri_decode", ({override}) => {
|
||||
assert.equal(util.robust_uri_decode("xxx%3Ayyy"), "xxx:yyy");
|
||||
assert.equal(util.robust_uri_decode("xxx%3"), "xxx");
|
||||
run_test("robust_url_decode", ({override}) => {
|
||||
assert.equal(util.robust_url_decode("xxx%3Ayyy"), "xxx:yyy");
|
||||
assert.equal(util.robust_url_decode("xxx%3"), "xxx");
|
||||
|
||||
override(global, "decodeURIComponent", () => {
|
||||
throw new Error("foo");
|
||||
});
|
||||
assert.throws(
|
||||
() => {
|
||||
util.robust_uri_decode("%E0%A4%A");
|
||||
util.robust_url_decode("%E0%A4%A");
|
||||
},
|
||||
{name: "Error", message: "foo"},
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue