Skip to content

Commit

Permalink
Disallow game names with spaces (#474)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jasonharrison authored and nicolodavis committed Sep 30, 2019
1 parent d43d239 commit 64971ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export function Game(game) {
if (game.playerView === undefined) game.playerView = G => G;
if (game.plugins === undefined) game.plugins = [];

if (game.name.includes(' ')) {
throw new Error(game.name + ': Game name must not include spaces');
}

const flow = Flow(game);

return {
Expand Down
7 changes: 7 additions & 0 deletions src/core/game.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,10 @@ test('serpentine setup phases', () => {
expect(client.getState().ctx.currentPlayer).toBe('1');
expect(client.getState().ctx.phase).toBe('main phase');
});

test('game name with spaces should raise Error', () => {
const game = () => {
Game({ name: 'tic tac toe' });
};
expect(game).toThrow();
});

0 comments on commit 64971ee

Please sign in to comment.