diff options
Diffstat (limited to 'src/client/util/reportManager/ReportManagerComponents.tsx')
-rw-r--r-- | src/client/util/reportManager/ReportManagerComponents.tsx | 21 |
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': |