Fix image uploading if character name contains a dot

This commit is contained in:
Cohee 2024-03-03 20:39:20 +02:00
parent c4cae9d00f
commit 7acd2916ec
2 changed files with 3 additions and 3 deletions

View File

@ -970,7 +970,7 @@ export async function saveBase64AsFile(base64Data, characterName, filename = '',
const requestBody = {
image: dataURL,
ch_name: characterName,
filename: filename,
filename: String(filename).replace(/\./g, '_'),
};
// Send the data URL to your backend using fetch

View File

@ -384,9 +384,9 @@ app.post('/uploadimage', jsonParser, async (request, response) => {
}
// if character is defined, save to a sub folder for that character
let pathToNewFile = path.join(DIRECTORIES.userImages, filename);
let pathToNewFile = path.join(DIRECTORIES.userImages, sanitize(filename));
if (request.body.ch_name) {
pathToNewFile = path.join(DIRECTORIES.userImages, request.body.ch_name, filename);
pathToNewFile = path.join(DIRECTORIES.userImages, sanitize(request.body.ch_name), sanitize(filename));
}
ensureDirectoryExistence(pathToNewFile);