feat: transform filename to name

This commit is contained in:
Timothy J. Baek 2024-01-08 01:32:55 -08:00
parent 54c4e0761a
commit fe997abc6d
2 changed files with 74 additions and 4 deletions

View file

@ -146,6 +146,19 @@ export const removeFirstHashWord = (inputString) => {
return resultString;
};
export const transformFileName = (fileName) => {
// Convert to lowercase
const lowerCaseFileName = fileName.toLowerCase();
// Remove special characters using regular expression
const sanitizedFileName = lowerCaseFileName.replace(/[^\w\s]/g, '');
// Replace spaces with dashes
const finalFileName = sanitizedFileName.replace(/\s+/g, '-');
return finalFileName;
};
export const calculateSHA256 = async (file) => {
// Create a FileReader to read the file asynchronously
const reader = new FileReader();