diff options
author | Sophie Zhang <sophie_zhang@brown.edu> | 2023-07-27 13:50:32 -0400 |
---|---|---|
committer | Sophie Zhang <sophie_zhang@brown.edu> | 2023-07-27 13:50:32 -0400 |
commit | 7535e446e9a8aa2a0afaf84c667f3a58f437d99b (patch) | |
tree | 78900f170d3669b8501d4af392431a9433be37ce | |
parent | 955ca75035aaa223fc8bc07416ca4c31e7a9d1c2 (diff) |
fixed media on localhost, not really practical but still:
-rw-r--r-- | src/client/util/reportManager/ReportManagerComponents.tsx | 21 | ||||
-rw-r--r-- | src/client/util/reportManager/reportManagerUtils.ts | 2 |
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; |