mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-02-17 02:22:23 +01:00
Merge pull request #2313 from MartinFournier/fix/import-save
Fix import save issue with large files
This commit is contained in:
@ -221,13 +221,6 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
const contents = result;
|
const contents = result;
|
||||||
|
|
||||||
// https://stackoverflow.com/a/35002237
|
|
||||||
const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
||||||
if (!base64regex.test(contents)) {
|
|
||||||
SnackbarEvents.emit("Save game was not a base64 string", "error", 5000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let newSave;
|
let newSave;
|
||||||
try {
|
try {
|
||||||
newSave = window.atob(contents);
|
newSave = window.atob(contents);
|
||||||
@ -237,7 +230,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!newSave || newSave === '') {
|
if (!newSave || newSave === '') {
|
||||||
SnackbarEvents.emit("Save game had not content", "error", 5000);
|
SnackbarEvents.emit("Save game had not content or was not base64 encoded", "error", 5000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user