mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
feat: transform filename to name
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user