aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/util/reportManager/ReportManagerComponents.tsx21
-rw-r--r--src/client/util/reportManager/reportManagerUtils.ts2
2 files changed, 22 insertions, 1 deletions
diff --git a/src/client/util/reportManager/ReportManagerComponents.tsx b/src/client/util/reportManager/ReportManagerComponents.tsx
index 8f882c7f2..e870c073d 100644
--- a/src/client/util/reportManager/ReportManagerComponents.tsx
+++ b/src/client/util/reportManager/ReportManagerComponents.tsx
@@ -120,6 +120,7 @@ export const IssueView = ({ issue }: IssueViewProps) => {
const audioTagRegex = /<audio\b[^>]*\/?>/;
const fileRegex = /https:\/\/browndash\.com\/files/;
+ const localRegex = /http:\/\/localhost:1050\/files/;
const parts = body.split('\n');
const modifiedParts = await Promise.all(
@@ -129,6 +130,9 @@ export const IssueView = ({ issue }: IssueViewProps) => {
} else if (fileRegex.test(part)) {
const tag = await parseDashFiles(part);
return tag;
+ } else if (localRegex.test(part)) {
+ const tag = await parseLocalFiles(part);
+ return tag;
} else {
return part;
}
@@ -189,6 +193,23 @@ export const IssueView = ({ issue }: IssueViewProps) => {
}
};
+ // Returns the corresponding HTML tag for a src url
+ const parseLocalFiles = async (url: string) => {
+ const imgRegex = /http:\/\/localhost:1050\/files[/\\]images/;
+ const dashVideoRegex = /http:\/\/localhost:1050\.com\/files[/\\]videos/;
+ const dashAudioRegex = /http:\/\/localhost:1050\.com\/files[/\\]audio/;
+
+ if (imgRegex.test(url)) {
+ return await getDisplayedFile(url, 'image');
+ } else if (dashVideoRegex.test(url)) {
+ return await getDisplayedFile(url, 'video');
+ } else if (dashAudioRegex.test(url)) {
+ return await getDisplayedFile(url, 'audio');
+ } else {
+ return url;
+ }
+ };
+
const getDisplayedFile = async (url: string, fileType: 'image' | 'video' | 'audio'): Promise<string> => {
switch (fileType) {
case 'image':
diff --git a/src/client/util/reportManager/reportManagerUtils.ts b/src/client/util/reportManager/reportManagerUtils.ts
index 45727e203..b95417aa1 100644
--- a/src/client/util/reportManager/reportManagerUtils.ts
+++ b/src/client/util/reportManager/reportManagerUtils.ts
@@ -84,7 +84,7 @@ export const formatTitle = (title: string, userEmail: string): string => `${titl
// C: /Users/dash/Documents/GitHub/Dash-Web/src/server/public/files/images/upload_8008dbc4b6424fbff14da7345bb32eb2.png
// -> https://browndash.com/files/images/upload_8008dbc4b6424fbff14da7345bb32eb2_l.png
export const fileLinktoServerLink = (fileLink: string): string => {
- const serverUrl = 'https://browndash.com/';
+ const serverUrl = window.location.href.includes('browndash') ? 'https://browndash.com/' : 'http://localhost:1050/';
const regex = 'public';
const publicIndex = fileLink.indexOf(regex) + regex.length;