Skip to content

Commit

Permalink
Check puz grid chars
Browse files Browse the repository at this point in the history
  • Loading branch information
mdirolf committed May 28, 2024
1 parent 145b6b1 commit 9ca64a8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/lib/converter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { ClueT, PuzzleInProgressStrictT, removeClueSpecials } from './types.js';
import {
ALLOWABLE_GRID_CHARS,
BLOCK,
ClueT,
EMPTY,
PuzzleInProgressStrictT,
removeClueSpecials,
} from './types.js';
import { fromCells, getClueMap } from './viewableGrid.js';

const EXTENSION_HEADER_LENGTH = 8;
Expand Down Expand Up @@ -133,8 +140,14 @@ class PuzReader {
if (val === ':') {
hidden.push(i);
grid.push('.');
} else {
} else if (
val === EMPTY ||
val === BLOCK ||
val.match(ALLOWABLE_GRID_CHARS)
) {
grid.push(val);
} else {
throw new Error(`Invalid character in grid at position ${i}`);
}
}

Expand Down

0 comments on commit 9ca64a8

Please sign in to comment.