From f5837c1b64994a15537a0b8df109bed504d0d20a Mon Sep 17 00:00:00 2001
From: Christopher Speller <crspeller@gmail.com>
Date: Tue, 21 Jul 2015 16:15:24 -0400
Subject: Old files are saved with full paths, this changes so that new files
 are not saved with absolute paths and detects old files saved and fixes them.

---
 web/react/components/post_body.jsx | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'web/react/components/post_body.jsx')

diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx
index d9678df30..96b441c0e 100644
--- a/web/react/components/post_body.jsx
+++ b/web/react/components/post_body.jsx
@@ -28,6 +28,12 @@ module.exports = React.createClass({
 
                 var type = utils.getFileType(fileInfo.ext);
 
+                // This is a temporary patch to fix issue with old files using absolute paths
+                if (fileInfo.path.indexOf("/api/v1/files/get") == -1) {
+                    fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
+                }
+                fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
+
                 if (type === "image") {
                     $('<img/>').attr('src', fileInfo.path+'_thumb.jpg').load(function(path, name){ return function() {
                         $(this).remove();
@@ -102,6 +108,12 @@ module.exports = React.createClass({
 
                 var type = utils.getFileType(fileInfo.ext);
 
+                // This is a temporary patch to fix issue with old files using absolute paths
+                if (fileInfo.path.indexOf("/api/v1/files/get") == -1) {
+                    fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
+                }
+                fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
+
                 if (type === "image") {
                     if (i < Constants.MAX_DISPLAY_FILES) {
                         postFiles.push(
-- 
cgit v1.2.3-1-g7c22

