1
0
Fork 0
mirror of synced 2024-08-18 19:41:30 +12:00

Fix for #10358 - making sure that client-side we don't check the content type for CSV, check if it might be JSON, if not assume we can try it as a CSV - this is a fix for an issue which occurs on Windows, in Firefox. (#10359)

This commit is contained in:
Michael Drury 2023-04-20 15:21:50 +01:00 committed by GitHub
parent d21f8435d6
commit 145c0834bb

View file

@ -42,16 +42,7 @@ export const parseFile = e => {
reader.addEventListener("load", function (e) {
const fileData = e.target.result
if (file.type === "text/csv") {
API.csvToJson(fileData)
.then(rows => {
resolveRows(rows)
})
.catch(() => {
reject("can't convert csv to json")
})
} else if (file.type === "application/json") {
if (file.type?.includes("json")) {
const parsedFileData = JSON.parse(fileData)
if (Array.isArray(parsedFileData)) {
@ -62,7 +53,13 @@ export const parseFile = e => {
reject("invalid json format")
}
} else {
reject("invalid file type")
API.csvToJson(fileData)
.then(rows => {
resolveRows(rows)
})
.catch(() => {
reject("cannot parse csv")
})
}
})