Skip to content

Commit

Permalink
Use || instead of ?? to catch empty strings as well
Browse files Browse the repository at this point in the history
  • Loading branch information
North101 authored and sgenoud committed Jan 17, 2025
1 parent a1444e9 commit f542d84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/studio/src/builder.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ try {
try {
return runInContext(editedText, {});
} catch (e) {
return {};
return null;
}
};

Expand Down
4 changes: 2 additions & 2 deletions packages/studio/src/utils/downloadCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import builderAPI from './builderAPI';

export default async (code, fileName) => {
fileName = fileName
?? await builderAPI.extractDefaultNameFromCode(code)
?? 'replicad-script'
|| await builderAPI.extractDefaultNameFromCode(code)
|| 'replicad-script'
return fileSave(
new Blob([code], {
type: "application/javascript",
Expand Down
6 changes: 3 additions & 3 deletions packages/studio/src/utils/saveShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export default async function saveShapes(shapeId, fileType = "stl", code) {
const ext = mapExt(fileType);

await fileSave(blob, {
fileName: `${name ?? defaultName ?? "shape"}.${ext}`,
fileName: `${name || defaultName || "shape"}.${ext}`,
extensions: [`.${ext}`],
description: `Save ${name ?? defaultName ?? "shape"} as ${fileType}`,
description: `Save ${name || defaultName || "shape"} as ${fileType}`,
});
return;
}
Expand All @@ -34,7 +34,7 @@ export default async function saveShapes(shapeId, fileType = "stl", code) {
await fileSave(zipBlob, {
id: "exports",
description: "Save zip",
fileName: `${defaultName ?? shapeId}.zip`,
fileName: `${defaultName || shapeId}.zip`,
extensions: [".zip"],
});
}

0 comments on commit f542d84

Please sign in to comment.