Split safely

This commit is contained in:
DD Liu committed 2018-07-12 15:57:55 -04:00
1 parent 33cb3df1a1
commit 955f328d1b
2 files changed
+4 -2

No files matched your search

+2 -1
View File
@@ -26,7 +26,8 @@ class CostumeLibrary extends React.PureComponent {
]);
}
handleItemSelected (item) {
const type = item.md5.split('.')[1];
const split = item.md5.split('.');
const type = split.length > 1 ? split[1] : null;
const rotationCenterX = type === 'svg' ? item.info[0] : item.info[0] / 2;
const rotationCenterY = type === 'svg' ? item.info[1] : item.info[1] / 2;
const vmCostume = {
+2 -1
View File
@@ -161,7 +161,8 @@ class CostumeTab extends React.Component {
}
handleSurpriseCostume () {
const item = costumeLibraryContent[Math.floor(Math.random() * costumeLibraryContent.length)];
const type = item.md5.split('.')[1];
const split = item.md5.split('.');
const type = split.length > 1 ? split[1] : null;
const rotationCenterX = type === 'svg' ? item.info[0] : item.info[0] / 2;
const rotationCenterY = type === 'svg' ? item.info[1] : item.info[1] / 2;
const vmCostume = {