Skip to content

Commit 5e35892

Browse files
committed
fix: unable to enable some layouts due to an incorrect schema
closes monkeytypegame#5948
1 parent 9f7aeac commit 5e35892

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

frontend/__tests__/root/config.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ describe("Config", () => {
439439
it("setKeymapLayout", () => {
440440
expect(Config.setKeymapLayout("overrideSync")).toBe(true);
441441
expect(Config.setKeymapLayout("override_sync")).toBe(true);
442-
expect(Config.setKeymapLayout("override sync")).toBe(true);
443-
expect(Config.setKeymapLayout("override-sync!")).toBe(true);
442+
expect(Config.setKeymapLayout("override sync")).toBe(false);
443+
expect(Config.setKeymapLayout("override-sync!")).toBe(false);
444444
expect(Config.setKeymapLayout(stringOfLength(50))).toBe(true);
445445

446446
expect(Config.setKeymapLayout(stringOfLength(51))).toBe(false);
@@ -451,7 +451,7 @@ describe("Config", () => {
451451
expect(Config.setLayout(stringOfLength(50))).toBe(true);
452452

453453
expect(Config.setLayout("semi mak")).toBe(false);
454-
expect(Config.setLayout("semi-mak")).toBe(false);
454+
expect(Config.setLayout("semi-mak")).toBe(true);
455455
expect(Config.setLayout(stringOfLength(51))).toBe(false);
456456
});
457457
it("setFontSize", () => {

frontend/static/layouts/_list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@
14191419
"row5": [" "]
14201420
}
14211421
},
1422-
"3l ": {
1422+
"3l": {
14231423
"keymapShowTopRow": false,
14241424
"type": "ansi",
14251425
"keys": {

packages/contracts/src/schemas/configs.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,13 @@ export type ThemeName = z.infer<typeof ThemeNameSchema>;
265265
export const KeymapLayoutSchema = z
266266
.string()
267267
.max(50)
268-
.regex(/[\w\-_]+/);
268+
.regex(/^[a-zA-Z0-9\-_]+$/gi);
269269
export type KeymapLayout = z.infer<typeof KeymapLayoutSchema>;
270270

271-
export const LayoutSchema = token().max(50);
271+
export const LayoutSchema = z
272+
.string()
273+
.max(50)
274+
.regex(/^[a-zA-Z0-9\-_]+$/gi);
272275
export type Layout = z.infer<typeof LayoutSchema>;
273276

274277
export const FontSizeSchema = z.number().positive();

0 commit comments

Comments
 (0)