Skip to content

Commit 64971ee

Browse files
jasonharrisonnicolodavis
authored andcommitted
Disallow game names with spaces (#474)
* WIP trying to fix #459 by replacing spaces with dashes * Revert changes in socketio.js and api.ts * Throw error if a game name has spaces
1 parent d43d239 commit 64971ee

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/core/game.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ export function Game(game) {
6767
if (game.playerView === undefined) game.playerView = G => G;
6868
if (game.plugins === undefined) game.plugins = [];
6969

70+
if (game.name.includes(' ')) {
71+
throw new Error(game.name + ': Game name must not include spaces');
72+
}
73+
7074
const flow = Flow(game);
7175

7276
return {

src/core/game.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,10 @@ test('serpentine setup phases', () => {
211211
expect(client.getState().ctx.currentPlayer).toBe('1');
212212
expect(client.getState().ctx.phase).toBe('main phase');
213213
});
214+
215+
test('game name with spaces should raise Error', () => {
216+
const game = () => {
217+
Game({ name: 'tic tac toe' });
218+
};
219+
expect(game).toThrow();
220+
});

0 commit comments

Comments
 (0)