diff --git a/companion/lib/Service/TcpUdpApi.ts b/companion/lib/Service/TcpUdpApi.ts index 13766bc040..1efabcf8d1 100644 --- a/companion/lib/Service/TcpUdpApi.ts +++ b/companion/lib/Service/TcpUdpApi.ts @@ -167,7 +167,7 @@ export class ServiceTcpUdpApi extends CoreBase { if (!control.stepMakeCurrent(step)) throw new ApiMessageError('Step out of range') }) - this.#router.addPath('style bank :page :bank text{ :text}', (match) => { + this.#router.addPath('style bank :page :bank text{ *text}', (match) => { this.#checkLegacyRouteAllowed() const controlId = this.page.getControlIdAtOldBankIndex(Number(match.page), Number(match.bank)) @@ -247,7 +247,7 @@ export class ServiceTcpUdpApi extends CoreBase { this.#router.addPath('location :page/:row/:column rotate-right', this.#locationRotateRight) this.#router.addPath('location :page/:row/:column set-step :step', this.#locationSetStep) - this.#router.addPath('location :page/:row/:column style text{ :text}', this.#locationStyleText) + this.#router.addPath('location :page/:row/:column style text{ *text}', this.#locationStyleText) this.#router.addPath('location :page/:row/:column style color :color', this.#locationStyleColor) this.#router.addPath('location :page/:row/:column style bgcolor :bgcolor', this.#locationStyleBgcolor) @@ -255,7 +255,7 @@ export class ServiceTcpUdpApi extends CoreBase { this.#router.addPath('surfaces rescan', this.#surfacesRescan) // custom variables - this.#router.addPath('custom-variable :name set-value {:value}', this.#customVariableSetValue) + this.#router.addPath('custom-variable :name set-value {*value}', this.#customVariableSetValue) } /** diff --git a/companion/test/Service/TcpUdpApi.test.ts b/companion/test/Service/TcpUdpApi.test.ts index de608554a0..585dbca51c 100644 --- a/companion/test/Service/TcpUdpApi.test.ts +++ b/companion/test/Service/TcpUdpApi.test.ts @@ -83,10 +83,23 @@ describe('TcpUdpApi', () => { mockFn.mockReturnValue(null) // Perform the request - await router.processMessage('custom-variable my-var-name set-value 123') + await router.processMessage('custom-variable my-var-name set-value 123 def') expect(mockFn).toHaveBeenCalledTimes(1) - expect(mockFn).toHaveBeenCalledWith('my-var-name', '123') + expect(mockFn).toHaveBeenCalledWith('my-var-name', '123 def') + }) + + test('ok from query with slash', async () => { + const { router, registry } = createService() + + const mockFn = registry.variables.custom.setValue + mockFn.mockReturnValue(null) + + // Perform the request + await router.processMessage('custom-variable my-var-name set-value 12/3 def') + + expect(mockFn).toHaveBeenCalledTimes(1) + expect(mockFn).toHaveBeenCalledWith('my-var-name', '12/3 def') }) test('ok empty', async () => { @@ -638,7 +651,36 @@ describe('TcpUdpApi', () => { registry.controls.getControl.mockReturnValue(mockControl) // Perform the request - router.processMessage('location 1/2/3 style text def') + router.processMessage('location 1/2/3 style text def two') + + expect(registry.page.getControlIdAt).toHaveBeenCalledTimes(1) + expect(registry.page.getControlIdAt).toHaveBeenCalledWith({ + pageNumber: 1, + row: 2, + column: 3, + }) + + expect(registry.controls.getControl).toHaveBeenCalledTimes(1) + expect(registry.controls.getControl).toHaveBeenCalledWith('abc') + + expect(mockControl.styleSetFields).toHaveBeenCalledTimes(1) + expect(mockControl.styleSetFields).toHaveBeenCalledWith({ text: 'def two' }) + }) + + test('ok with slash', async () => { + const { router, registry } = createService() + registry.page.getControlIdAt.mockReturnValue('abc') + + const mockControl = mock( + { + styleSetFields: vi.fn(), + }, + mockOptions + ) + registry.controls.getControl.mockReturnValue(mockControl) + + // Perform the request + router.processMessage('location 1/2/3 style text de/f two') expect(registry.page.getControlIdAt).toHaveBeenCalledTimes(1) expect(registry.page.getControlIdAt).toHaveBeenCalledWith({ @@ -651,7 +693,7 @@ describe('TcpUdpApi', () => { expect(registry.controls.getControl).toHaveBeenCalledWith('abc') expect(mockControl.styleSetFields).toHaveBeenCalledTimes(1) - expect(mockControl.styleSetFields).toHaveBeenCalledWith({ text: 'def' }) + expect(mockControl.styleSetFields).toHaveBeenCalledWith({ text: 'de/f two' }) }) test('ok no text', async () => {