Skip to content

Commit

Permalink
trim .mid or any other extension off of filename when saving as bgm
Browse files Browse the repository at this point in the history
  • Loading branch information
Wrymouth committed Oct 18, 2022
1 parent bd665b1 commit ab79f53
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mamar-web/src/app/header/BgmActionGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import OpenButton from "./OpenButton"

import { useDoc, useRoot } from "../store"

function trimFileName(filename: string) {
const index = filename.lastIndexOf(".")
return index === -1 ? filename : filename.substring(0, index)
}

export default function BgmActionGroup() {
const [, dispatch] = useRoot()
const [doc, docDispatch] = useDoc()
Expand All @@ -25,8 +30,10 @@ export default function BgmActionGroup() {
throw new Error(bgmBin)
}

const filename = trimFileName(doc.name) + ".bgm"

const handle = await fileSave(new Blob([bgmBin]), {
fileName: `${doc.name}.bgm`,
fileName: filename,
extensions: [".bgm"],
}, saveAs ? undefined : doc.fileHandle)

Expand Down

0 comments on commit ab79f53

Please sign in to comment.