Ver Fonte

Enable Handling of Windows zipped Files

Nesta Bentum há 4 anos atrás
pai
commit
16c1bae1bd

+ 45 - 9
report-viewer/package-lock.json

@@ -16,6 +16,7 @@
         "highlight.js": "^11.6.0",
         "jszip": "^3.10.0",
         "node-polyfill-webpack-plugin": "^2.0.0",
+        "slash": "^4.0.0",
         "vue": "^3.2.37",
         "vue-chart-3": "^3.1.8",
         "vue-draggable-next": "^2.1.1",
@@ -5505,6 +5506,15 @@
         "url": "https://github.com/sponsors/sindresorhus"
       }
     },
+    "node_modules/del/node_modules/slash": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
+      "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
+      "dev": true,
+      "engines": {
+        "node": ">=8"
+      }
+    },
     "node_modules/depd": {
       "version": "1.1.2",
       "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
@@ -7221,6 +7231,15 @@
         "url": "https://github.com/sponsors/sindresorhus"
       }
     },
+    "node_modules/globby/node_modules/slash": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
+      "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
+      "dev": true,
+      "engines": {
+        "node": ">=8"
+      }
+    },
     "node_modules/graceful-fs": {
       "version": "4.2.9",
       "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz",
@@ -11712,12 +11731,14 @@
       }
     },
     "node_modules/slash": {
-      "version": "3.0.0",
-      "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
-      "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
-      "dev": true,
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
+      "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==",
       "engines": {
-        "node": ">=8"
+        "node": ">=12"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
       }
     },
     "node_modules/slice-ansi": {
@@ -17892,6 +17913,14 @@
         "p-map": "^4.0.0",
         "rimraf": "^3.0.2",
         "slash": "^3.0.0"
+      },
+      "dependencies": {
+        "slash": {
+          "version": "3.0.0",
+          "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
+          "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
+          "dev": true
+        }
       }
     },
     "depd": {
@@ -19175,6 +19204,14 @@
         "ignore": "^5.2.0",
         "merge2": "^1.4.1",
         "slash": "^3.0.0"
+      },
+      "dependencies": {
+        "slash": {
+          "version": "3.0.0",
+          "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
+          "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
+          "dev": true
+        }
       }
     },
     "graceful-fs": {
@@ -22465,10 +22502,9 @@
       }
     },
     "slash": {
-      "version": "3.0.0",
-      "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
-      "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
-      "dev": true
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
+      "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew=="
     },
     "slice-ansi": {
       "version": "5.0.0",

+ 1 - 0
report-viewer/package.json

@@ -16,6 +16,7 @@
     "highlight.js": "^11.6.0",
     "jszip": "^3.10.0",
     "node-polyfill-webpack-plugin": "^2.0.0",
+    "slash": "^4.0.0",
     "vue": "^3.2.37",
     "vue-chart-3": "^3.1.8",
     "vue-draggable-next": "^2.1.1",

+ 10 - 7
report-viewer/src/views/FileUploadView.vue

@@ -25,6 +25,7 @@ import router from "@/router";
 import store from "@/store/store";
 import { getFileExtension } from "@/utils/Utils";
 import path from "path";
+import slash from "slash";
 
 export default defineComponent({
   name: "FileUploadView",
@@ -66,22 +67,24 @@ export default defineComponent({
      */
     const handleZipFile = (file: File) => {
       jszip.loadAsync(file).then(async (zip) => {
-        for (const fileName of Object.keys(zip.files)) {
+        for (const originalFileName of Object.keys(zip.files)) {
+          const unixFileName = slash(originalFileName);
           if (
-            /((.+\/)*)submissions\/(.+)\/(.+)/.test(fileName) &&
-            !/^__MACOSX\//.test(fileName)
+            /((.+\/)*)submissions\/(.+)\/(.+)/.test(unixFileName) &&
+            !/^__MACOSX\//.test(unixFileName)
           ) {
-            const filePath = path.parse(fileName);
+            const filePath = path.parse(unixFileName);
+
             const submissionFileName = extractSubmissionFileName(filePath);
-            await zip.files[fileName].async("string").then((data) => {
+            await zip.files[originalFileName].async("string").then((data) => {
               store.commit("saveSubmissionFile", {
                 name: submissionFileName,
                 file: { fileName: filePath.base, data: data },
               });
             });
           } else {
-            await zip.files[fileName].async("string").then((data) => {
-              store.commit("saveFile", { fileName: fileName, data: data });
+            await zip.files[originalFileName].async("string").then((data) => {
+              store.commit("saveFile", { fileName: unixFileName, data: data });
             });
           }
         }