fix: real project README and save-file version validation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,4 +20,8 @@ describe('notation', () => {
|
||||
it('rejects a file that is not a duplicate-chess save', () => {
|
||||
expect(() => deserialize('{"variant":"chess","version":1,"moves":[]}')).toThrow();
|
||||
});
|
||||
|
||||
it('rejects an unsupported save version', () => {
|
||||
expect(() => deserialize('{"variant":"duplicate-chess","version":99,"moves":[]}')).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,5 +21,8 @@ export function deserialize(json: string): HistoryEntry[] {
|
||||
if (data.variant !== 'duplicate-chess' || !Array.isArray(data.moves)) {
|
||||
throw new Error('Not a duplicate-chess save file');
|
||||
}
|
||||
if (data.version !== 1) {
|
||||
throw new Error('Unsupported save version');
|
||||
}
|
||||
return data.moves;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user