Skip to content

Commit

Permalink
wip: Update folder/file Regex check
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobiClark committed Oct 4, 2024
1 parent 86881b7 commit 2625076
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/renderer/src/scripts/others/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4350,23 +4350,24 @@ window.replaceProblematicFilesWithSDSCompliantNames = (datasetStructure) => {
// }
// };

const namesOfForbiddenFiles = {
const forbiddenFiles = {
".DS_Store": true,
"Thumbs.db": true,
};

const sparcFolderAndFileRegex = /[\+&\%#]/;
const validSparcFolderAndFileNameRegex = /^[0-9A-Za-z,.-_ ]+$/;
const identifierConventionsRegex = /^[a-zA-Z0-9-_]+$/;

window.evaluateStringAgainstSdsRequirements = (stringToTest, stringCase) => {
const testCases = {
"folder-and-file-name-is-valid": !sparcFolderAndFileRegex.test(stringToTest), // returns true if the string is valid
"file-is-hidden": stringToTest.startsWith("."), // returns true if the string is hidden
"file-is-in-forbidden-files-list": namesOfForbiddenFiles?.[stringToTest], // returns true if the string is in the forbidden files list
"string-adheres-to-identifier-conventions": identifierConventionsRegex.test(stringToTest), // returns true if the string adheres to the identifier conventions
window.evaluateStringAgainstSdsRequirements = (stringToTest, testType) => {
const tests = {
"is-valid-folder-or-file-name": validSparcFolderAndFileNameRegex.test(stringToTest),
"is-hidden-file": stringToTest.startsWith("."),
"is-forbidden-file": forbiddenFiles[stringToTest] === true,
"adheres-to-identifier-conventions": identifierConventionsRegex.test(stringToTest),
};
return testCases[stringCase];
return tests[testType];
};

let loadingSweetAlert;
let loadingSweetAlertTimer;

Expand Down

0 comments on commit 2625076

Please sign in to comment.