From 13e43b874719fd4aada18771ffd7c4e0bb972cb5 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Tue, 3 Jun 2025 20:27:40 -0700 Subject: [PATCH] fix: Handle spaces in PTZ presets (#2084) - Closes #2079 --- src/utils/basic.ts | 2 +- tests/utils/basic.test.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/basic.ts b/src/utils/basic.ts index 6f499f5a..7bdb9c22 100644 --- a/src/utils/basic.ts +++ b/src/utils/basic.ts @@ -21,7 +21,7 @@ export function prettifyTitle(input?: string): string | undefined { if (!input) { return undefined; } - const words = input.split(/[_\s]+/); + const words = input.trim().split(/[_\s]+/); return words .map((word) => { return word[0].toUpperCase() + word.substring(1); diff --git a/tests/utils/basic.test.ts b/tests/utils/basic.test.ts index 5300a4e3..47bac62b 100644 --- a/tests/utils/basic.test.ts +++ b/tests/utils/basic.test.ts @@ -36,6 +36,12 @@ describe('prettifyTitle', () => { it('should prettify words', () => { expect(prettifyTitle('this is_a string')).toBe('This Is A String'); }); + it('should handle leading spaces', () => { + expect(prettifyTitle(' this is_a string')).toBe('This Is A String'); + }); + it('should handle empty string', () => { + expect(prettifyTitle('')).toBeUndefined(); + }); }); describe('arrayMove', () => {