Skip to content

Commit a44de05

Browse files
Fix remove file extension in web
1 parent 5b4f182 commit a44de05

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

frontend/src/state-providers/portfolio.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,16 @@ export function createPortfolioState(editor: Editor) {
6262
}
6363
});
6464
editor.subscriptions.subscribeJsMessage(TriggerOpenDocument, async () => {
65-
const extension = editor.handle.fileExtension();
66-
const data = await upload("." + extension, "text");
67-
editor.handle.openDocumentFile(data.filename, data.content);
65+
const suffix = "." + editor.handle.fileExtension();
66+
const data = await upload(suffix, "text");
67+
68+
// Use filename as document name, removing the extension if it exists
69+
var documentName = data.filename;
70+
if (documentName.endsWith(suffix)) {
71+
documentName = documentName.slice(0, -suffix.length);
72+
}
73+
74+
editor.handle.openDocumentFile(documentName, data.content);
6875
});
6976
editor.subscriptions.subscribeJsMessage(TriggerImport, async () => {
7077
const data = await upload("image/*", "both");

0 commit comments

Comments
 (0)