🐛 Fix json file name

This commit is contained in:
Eva Marco 2026-08-05 09:55:42 +02:00
parent 1f22804f6a
commit 208b5da392
2 changed files with 11 additions and 4 deletions

View File

@ -318,7 +318,9 @@ export class ShortcutsPage extends BaseWebSocketPage {
this.exportShortcuts(),
]);
expect(download.suggestedFilename()).toBe("penpot-shortcuts.json");
expect(download.suggestedFilename()).toMatch(
/^penpot-shortcuts-Princesa_Leia-\d{4}-\d{2}-\d{2}\.json$/,
);
const path = await download.path();
const content = await readFile(path, "utf-8");

View File

@ -424,11 +424,16 @@
on-export
(mf/use-fn
(mf/deps shortcuts-json has-custom-shortcuts)
(mf/deps shortcuts-json has-custom-shortcuts (:fullname profile))
(fn []
(when has-custom-shortcuts
(->> (wapi/create-blob shortcuts-json "application/json")
(dom/trigger-download "penpot-shortcuts.json")))))
(let [fullname (-> (or (:fullname profile) "user")
(str/replace #"[^a-zA-Z0-9\-_ ]" "")
(str/replace #"\s+" "_"))
date (.slice (.toISOString (js/Date.)) 0 10)
filename (str "penpot-shortcuts-" fullname "-" date ".json")]
(->> (wapi/create-blob shortcuts-json "application/json")
(dom/trigger-download filename))))))
on-file-selected
(mf/use-fn