mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
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.
17 lines
681 B
TypeScript
17 lines
681 B
TypeScript
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)
|
|
})
|
|
})
|