forked from open-webui/open-webui
feat: transform filename to name
This commit is contained in:
parent
54c4e0761a
commit
fe997abc6d
2 changed files with 74 additions and 4 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue