summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2016-01-06 09:54:05 -0500
committerhmhealey <harrisonmhealey@gmail.com>2016-01-06 09:54:05 -0500
commita6ba1a17fe22a72d7058621cb29e9f60d9de0a08 (patch)
tree53fec096f1e388538553067e545d01189c8edaf2 /web
parent239d147d9757c62cbfb6ae7b2900b0e5ace6f71c (diff)
downloadchat-a6ba1a17fe22a72d7058621cb29e9f60d9de0a08.tar.gz
chat-a6ba1a17fe22a72d7058621cb29e9f60d9de0a08.tar.bz2
chat-a6ba1a17fe22a72d7058621cb29e9f60d9de0a08.zip
Removed temporary fix for old filenames that used absolute urls pointing to the get file api
Diffstat (limited to 'web')
-rw-r--r--web/react/components/file_attachment.jsx4
-rw-r--r--web/react/components/file_preview.jsx7
-rw-r--r--web/react/utils/utils.jsx18
3 files changed, 3 insertions, 26 deletions
diff --git a/web/react/components/file_attachment.jsx b/web/react/components/file_attachment.jsx
index 2474b3d8a..c10269680 100644
--- a/web/react/components/file_attachment.jsx
+++ b/web/react/components/file_attachment.jsx
@@ -125,10 +125,6 @@ export default class FileAttachment extends React.Component {
getFileInfoFromName(name) {
var fileInfo = utils.splitFileLocation(name);
- // 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 = utils.getWindowLocationOrigin() + '/api/v1/files/get' + fileInfo.path;
return fileInfo;
diff --git a/web/react/components/file_preview.jsx b/web/react/components/file_preview.jsx
index d625a811e..265d3f367 100644
--- a/web/react/components/file_preview.jsx
+++ b/web/react/components/file_preview.jsx
@@ -35,12 +35,7 @@ export default class FilePreview extends React.Component {
var ext = filenameSplit[filenameSplit.length - 1];
var type = Utils.getFileType(ext);
- // This is a temporary patch to fix issue with old files using absolute paths
-
- if (filename.indexOf('/api/v1/files/get') !== -1) {
- filename = filename.split('/api/v1/files/get')[1];
- }
- filename = Utils.getWindowLocationOrigin() + '/api/v1/files/get' + filename + '?' + Utils.getSessionIndex();
+ filename = Utils.getFileUrl(filename);
if (type === 'image') {
previews.push(
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 41ede7712..e84fdf671 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -533,13 +533,7 @@ export function getPreviewImagePath(filename) {
const fileType = getFileType(fileInfo.ext);
if (fileType === 'image') {
- // 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 = getWindowLocationOrigin() + '/api/v1/files/get' + fileInfo.path;
-
- return fileInfo.path + '_preview.jpg?' + getSessionIndex();
+ return getFileUrl(fileInfo.path + '_preview.jpg');
}
// only images have proper previews, so just use a placeholder icon for non-images
@@ -1069,15 +1063,7 @@ export function fileSizeToString(bytes) {
// Converts a filename (like those attached to Post objects) to a url that can be used to retrieve attachments from the server.
export function getFileUrl(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 = getWindowLocationOrigin() + '/api/v1/files/get' + url + '?' + getSessionIndex();
-
- return url;
+ return getWindowLocationOrigin() + '/api/v1/files/get' + filename + '?' + getSessionIndex();
}
// Gets the name of a file (including extension) from a given url or file path.