From e1efc192ec6105c97c59f313e6efcbc617ff65d5 Mon Sep 17 00:00:00 2001
From: Michael Foiani <sotech117@michaels-mbp-5.devices.brown.edu>
Date: Thu, 25 Aug 2022 00:14:32 -0400
Subject: update the way to show the links

---
 src/client/util/ReportManager.tsx | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

(limited to 'src/client/util/ReportManager.tsx')

diff --git a/src/client/util/ReportManager.tsx b/src/client/util/ReportManager.tsx
index b36e7e063..d680b47ac 100644
--- a/src/client/util/ReportManager.tsx
+++ b/src/client/util/ReportManager.tsx
@@ -104,6 +104,20 @@ export class ReportManager extends React.Component<{}> {
         }
     }
 
+    // turns an upload link into a servable link
+    // ex: 
+    // C: /Users/dash/Documents/GitHub/Dash-Web/src/server/public/files/images/upload_8008dbc4b6424fbff14da7345bb32eb2_l.png
+    // -> http://localhost:1050/files/images/upload_8008dbc4b6424fbff14da7345bb32eb2_l.png
+    private fileLinktoServerLink = (fileLink: string) => {
+        const serverUrl = 'https://browndash.com/';
+
+        const regex = 'public'
+        const publicIndex = fileLink.indexOf(regex) + regex.length;
+
+        const finalUrl = `${serverUrl}${fileLink.substring(publicIndex + 1)}`;
+        return finalUrl;
+    }
+
     public async reportIssue() {
         if (this.bugTitle === '' || this.bugDescription === ''
             || this.bugType === '' || this.bugPriority === '') {
@@ -111,14 +125,15 @@ export class ReportManager extends React.Component<{}> {
             return;
         }
 
-
         if (this.toGithub) {
 
+            const formattedLinks = (this.fileLinks ?? []).map(this.fileLinktoServerLink)
+            
             const req = await this.octokit.request('POST /repos/{owner}/{repo}/issues', {
                 owner: 'brown-dash',
                 repo: 'Dash-Web',
                 title: this.formatTitle(this.bugTitle, Doc.CurrentUserEmail),
-                body: `${this.bugDescription} \n\nfiles:\n${(this.fileLinks ?? []).join('\n')}`,
+                body: `${this.bugDescription} \n\nfiles:\n${formattedLinks.join('\n')}`,
                 labels: [
                     'from-dash-app',
                     this.bugType,
-- 
cgit v1.2.3-70-g09d2

