From 86ac70678bf220df28bcc33148cd2580695a2b61 Mon Sep 17 00:00:00 2001 From: Rick Companje Date: Sun, 6 Jun 2021 20:55:49 +0200 Subject: [PATCH] strip path and extension when loading doodle from file --- src/js/actions/files.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/js/actions/files.js b/src/js/actions/files.js index c33f200..adfc2c4 100644 --- a/src/js/actions/files.js +++ b/src/js/actions/files.js @@ -120,8 +120,12 @@ export const openFileSelector = () => { const imgBlob = await generateThumb(sketcherState, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, 'blob'); const sketchBlob = new Blob([sketchData], { type: 'application/json' }); + let name = /[^/]*$/.exec(fileName)[0]; //remove path + if (name) name = name.replace(".doodle3d",""); //remove extension + if (!name) name = fileName; //fallback to fileName if needed + const doc = { - name: fileName.replace(".doodle3d",""), + name: name, appVersion: VERSION, _attachments: { img: { content_type: imgBlob.type, data: imgBlob },