Skip to content

Commit

Permalink
Fix bug related to undefined and null fileName in isGalaxyFile()
Browse files Browse the repository at this point in the history
  • Loading branch information
GomeChas committed Jul 18, 2024
1 parent 9201780 commit 4d59025
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/src/utils/upload-payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export function isUrl(content) {
}

export function isGalaxyFile(content) {
if (content === undefined || content === null) {
return false;
}
const galaxyRegexPattern = /Galaxy\d+-\[(.*?)\](\..+)/;
const match = content.match(galaxyRegexPattern);
if (match) {
Expand All @@ -39,10 +42,11 @@ export function uploadPayload(items, historyId, composite = false) {
if (fileName === DEFAULT_FILE_NAME) {
fileName = null;
}
if (isGalaxyFile(fileName)) {
const modifiedFileName = fileName.replace(/Galaxy\d+-\[(.*?)\](\..+)/, "$1");
const keepModifiedName = confirm(`This looks like a previous Galaxy file. We have renamed it.\n\nOriginal Name: ${fileName}\nModified Name: ${modifiedFileName}\n\n Do you want to keep the modified name?`)
if (isGalaxyFile(item.fileName)) {
const modifiedFileName = item.fileName.replace(/Galaxy\d+-\[(.*?)\](\..+)/, "$1");
const keepModifiedName = confirm(`This looks like a previous Galaxy file. We have renamed it.\n\nOriginal Name: ${item.fileName}\nModified Name: ${modifiedFileName}\n\n Do you want to keep the modified name?`)
if (keepModifiedName) {
item.fileName = modifiedFileName;
fileName = modifiedFileName;
}
}
Expand Down

0 comments on commit 4d59025

Please sign in to comment.