fix(stt): accept speech endpoints configured with a trailing /v1

An endpoint saved as http://host/v1 was turned into /v1/v1/audio/transcriptions
and every transcription returned 404. Strip a trailing /v1 when deriving the
server base URL, which also covers TTS and model discovery.
This commit is contained in:
Chris Scott committed 2026-10-23 14:08:33 -04:00
1 parent 811c22c7ec
commit 10190940bd
2 files changed
+17

No files matched your search

+1
View File
@@ -15,6 +15,7 @@ export function normalizeToBaseUrl(endpoint: string): string {
.replace(/\/v1\/audio\/transcriptions$/, '')
.replace(/\/audio\/transcriptions$/, '')
.replace(/\/$/, '')
.replace(/\/v1$/, '')
}
async function ensureDiscoveryCacheDir(): Promise<void> {
@@ -0,0 +1,16 @@
import { describe, expect, it } from 'vitest'
import { normalizeToBaseUrl } from '../../src/utils/discovery-cache'
describe('normalizeToBaseUrl', () => {
it.each([
['http://host:9000', 'http://host:9000'],
['http://host:9000/', 'http://host:9000'],
['http://host:9000/v1', 'http://host:9000'],
['http://host:9000/v1/', 'http://host:9000'],
['http://host:9000/v1/audio/transcriptions', 'http://host:9000'],
['http://host:8880/v1/audio/speech', 'http://host:8880'],
['http://host:8880/audio/speech', 'http://host:8880'],
])('reduces %s to the server base %s', (endpoint, expected) => {
expect(normalizeToBaseUrl(endpoint)).toBe(expected)
})
})