@@ -4,6 +4,7 @@ import { describe, it, expect, vi, afterEach } from "vitest"
44import {
55 ghostServiceSettingsSchema ,
66 getAppUrl ,
7+ getApiUrl ,
78 getKiloUrlFromToken ,
89 getExtensionConfigUrl ,
910} from "../kilocode/kilocode.js"
@@ -66,6 +67,34 @@ describe("URL functions", () => {
6667 it ( "should use subdomain structure for production" , ( ) => {
6768 expect ( getExtensionConfigUrl ( ) ) . toBe ( "https://api.kilo.ai/extension-config.json" )
6869 } )
70+ it ( "should use path structure for custom backend URLs" , ( ) => {
71+ process . env . KILOCODE_BACKEND_BASE_URL = "http://192.168.200.70:3000"
72+ expect ( getExtensionConfigUrl ( ) ) . toBe ( "http://192.168.200.70:3000/extension-config.json" )
73+ } )
74+ } )
75+
76+ describe ( "getApiUrl" , ( ) => {
77+ it ( "should handle production URLs with api subdomain" , ( ) => {
78+ expect ( getApiUrl ( ) ) . toBe ( "https://api.kilo.ai/" )
79+ expect ( getApiUrl ( "/trpc/cliSessions.get" ) ) . toBe ( "https://api.kilo.ai/trpc/cliSessions.get" )
80+ expect ( getApiUrl ( "/api/profile" ) ) . toBe ( "https://api.kilo.ai/api/profile" )
81+ } )
82+
83+ it ( "should handle localhost development URLs" , ( ) => {
84+ process . env . KILOCODE_BACKEND_BASE_URL = "http://localhost:3000"
85+
86+ expect ( getApiUrl ( ) ) . toBe ( "http://localhost:3000/" )
87+ expect ( getApiUrl ( "/api/trpc/cliSessions.get" ) ) . toBe ( "http://localhost:3000/api/trpc/cliSessions.get" )
88+ expect ( getApiUrl ( "/api/profile" ) ) . toBe ( "http://localhost:3000/api/profile" )
89+ } )
90+
91+ it ( "should handle custom backend URLs (non-localhost)" , ( ) => {
92+ process . env . KILOCODE_BACKEND_BASE_URL = "http://192.168.200.70:3000"
93+
94+ expect ( getApiUrl ( ) ) . toBe ( "http://192.168.200.70:3000/" )
95+ expect ( getApiUrl ( "/api/trpc/cliSessions.get" ) ) . toBe ( "http://192.168.200.70:3000/api/trpc/cliSessions.get" )
96+ expect ( getApiUrl ( "/api/profile" ) ) . toBe ( "http://192.168.200.70:3000/api/profile" )
97+ } )
6998 } )
7099
71100 describe ( "getAppUrl" , ( ) => {
0 commit comments