summaryrefslogtreecommitdiffstats
path: root/web/react/utils/utils.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r--web/react/utils/utils.jsx13
1 files changed, 13 insertions, 0 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index e48ffed9a..d1513dea9 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -894,3 +894,16 @@ module.exports.fileSizeToString = function(bytes) {
return bytes + "B";
}
};
+
+// Converts a filename (like those attached to Post objects) to a url that can be used to retrieve attachments from the server.
+module.exports.getFileUrl = function(filename) {
+ var url = filename;
+
+ // This is a temporary patch to fix issue with old files using absolute paths
+ if (url.indexOf("/api/v1/files/get") != -1) {
+ url = filename.split("/api/v1/files/get")[1];
+ }
+ url = module.exports.getWindowLocationOrigin() + "/api/v1/files/get" + url;
+
+ return url;
+};