aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/reportManager/ReportManagerComponents.tsx
diff options
context:
space:
mode:
authorSophie Zhang <sophie_zhang@brown.edu>2023-07-27 14:01:10 -0400
committerSophie Zhang <sophie_zhang@brown.edu>2023-07-27 14:01:10 -0400
commitd655a8770ae4d4ff3cf08c433ac9068ed975aee4 (patch)
tree41a710f1034e8ef095b0a9fe10f59e8fe33d227c /src/client/util/reportManager/ReportManagerComponents.tsx
parent4ad1c765afcb0402f00ea6a91bf5811904e2a30e (diff)
parent23382da2326108b8c81906ec9b353b3493c20a21 (diff)
Merge branch 'sophie-report-manager' into sophie-ai-images
Diffstat (limited to 'src/client/util/reportManager/ReportManagerComponents.tsx')
-rw-r--r--src/client/util/reportManager/ReportManagerComponents.tsx21
1 files changed, 21 insertions, 0 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':