Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

upload: Don’t convert relative upload URLs to absolute.

Anders Kaseorge0f4013b217d
diff --git a/frontend_tests/node_tests/upload.js b/frontend_tests/node_tests/upload.js
index f7f90990ef9..8dd3eb0ce06 100644
--- a/frontend_tests/node_tests/upload.js
+++ b/frontend_tests/node_tests/upload.js
@@ -54,15 +54,6 @@ test("feature_check", ({override}) => {
assert.ok(!upload_button.hasClass("notdisplayed"));
});
-test("make_upload_absolute", () => {
- let uri = "/user_uploads/5/d4/6lSlfIPIg9nDI2Upj0Mq_EbE/kerala.png";
- const expected_uri = "https://foo.com/user_uploads/5/d4/6lSlfIPIg9nDI2Upj0Mq_EbE/kerala.png";
- assert.equal(upload.make_upload_absolute(uri), expected_uri);
-
- uri = "https://foo.com/user_uploads/5/d4/6lSlfIPIg9nDI2Upj0Mq_EbE/alappuzha.png";
- assert.equal(upload.make_upload_absolute(uri), uri);
-});
-
test("get_item", () => {
assert.equal(upload.get_item("textarea", {mode: "compose"}), $("#compose-textarea"));
assert.equal(
@@ -532,7 +523,7 @@ test("uppy_events", ({override}) => {
assert.equal(old_syntax, "[translated: Uploading copenhagen.png…]()");
assert.equal(
new_syntax,
- "[copenhagen.png](https://foo.com/user_uploads/4/cb/rue1c-MlMUjDAUdkRrEM4BTJ/copenhagen.png)",
+ "[copenhagen.png](/user_uploads/4/cb/rue1c-MlMUjDAUdkRrEM4BTJ/copenhagen.png)",
);
assert.equal(textarea, $("#compose-textarea"));
});
diff --git a/static/js/upload.js b/static/js/upload.js
index d1dc740171a..7449fa329a9 100644
--- a/static/js/upload.js
+++ b/static/js/upload.js
@@ -11,14 +11,6 @@ import {csrf_token} from "./csrf";
import {$t} from "./i18n";
import {page_params} from "./page_params";
-export function make_upload_absolute(uri) {
- if (uri.startsWith(compose.uploads_path)) {
- // Rewrite the URI to a usable link
- return compose.uploads_domain + uri;
- }
- return uri;
-}
-
// Show the upload button only if the browser supports it.
export function feature_check(upload_button) {
if (window.XMLHttpRequest && new window.XMLHttpRequest().upload) {
@@ -255,8 +247,7 @@ export function setup_upload(config) {
if (config.mode === "compose" && !compose_state.composing()) {
compose_actions.start("stream");
}
- const absolute_uri = make_upload_absolute(uri);
- const filename_uri = "[" + filename + "](" + absolute_uri + ")";
+ const filename_uri = "[" + filename + "](" + uri + ")";
compose_ui.replace_syntax(
get_translated_status(file),
filename_uri,