mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-06 00:05:30 +00:00
fix(ccswitch): trim trailing slashes before Antigravity path
This commit is contained in:
1 parent
efe9aab1e4
commit
d054ee9af3
2 files changed
+23
-1
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { buildCcSwitchImportDeeplink } from '../ccswitchImport'
|
||||
|
||||
describe('Antigravity CC Switch endpoint', () => {
|
||||
it.each([
|
||||
['https://api.example.com', 'https://api.example.com/antigravity'],
|
||||
['https://api.example.com/', 'https://api.example.com/antigravity'],
|
||||
['https://api.example.com///', 'https://api.example.com/antigravity'],
|
||||
['https://api.example.com/sub2api/', 'https://api.example.com/sub2api/antigravity']
|
||||
])('joins the platform path onto %s for both clients', (baseUrl, endpoint) => {
|
||||
for (const clientType of ['claude', 'gemini'] as const) {
|
||||
const url = new URL(buildCcSwitchImportDeeplink({
|
||||
baseUrl, clientType, platform: 'antigravity', providerName: 'Sub2API',
|
||||
apiKey: 'sk-test', usageScript: 'return true'
|
||||
}))
|
||||
expect(url.searchParams.get('endpoint')).toBe(endpoint)
|
||||
expect(url.searchParams.get('app')).toBe(clientType)
|
||||
expect(url.searchParams.get('homepage')).toBe(baseUrl)
|
||||
expect(url.searchParams.has('model')).toBe(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -34,7 +34,7 @@ export function resolveCcSwitchImportConfig(
|
||||
case 'antigravity':
|
||||
return {
|
||||
app: clientType === 'gemini' ? 'gemini' : 'claude',
|
||||
endpoint: `${baseUrl}/antigravity`
|
||||
endpoint: `${baseUrl.replace(/\/+$/, '')}/antigravity`
|
||||
}
|
||||
case 'openai':
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user