File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -190,17 +190,23 @@ describe("pi/glance", () => {
190190
191191 const session = {
192192 id : "session-1" ,
193- url : "https://glance.sh /s/session-1" ,
193+ url : "/s/session-1" ,
194194 } satisfies SessionResponse ;
195195
196196 const fetchMock = vi . fn ( async ( ) => jsonResponse ( session ) ) ;
197197 vi . stubGlobal ( "fetch" , fetchMock ) ;
198198
199- await expect ( __testing . createSession ( ) ) . resolves . toEqual ( session ) ;
199+ await expect ( __testing . createSession ( ) ) . resolves . toEqual ( {
200+ ...session ,
201+ url : "https://glance.sh/s/session-1" ,
202+ } ) ;
200203 expect ( fetchMock ) . toHaveBeenCalledWith ( "https://glance.sh/api/session" , {
201204 method : "POST" ,
202205 } ) ;
203- expect ( __testing . getState ( ) . currentSession ) . toEqual ( session ) ;
206+ expect ( __testing . getState ( ) . currentSession ) . toEqual ( {
207+ ...session ,
208+ url : "https://glance.sh/s/session-1" ,
209+ } ) ;
204210 expect ( __testing . isSessionStale ( ) ) . toBe ( false ) ;
205211
206212 vi . setSystemTime ( new Date ( "2026-03-07T15:08:00.001Z" ) ) ;
Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ interface GlanceDetails {
4646 expiresAt ?: number ;
4747}
4848
49+ function normalizeSessionUrl ( url : string ) : string {
50+ return new URL ( url , BASE_URL ) . toString ( ) ;
51+ }
52+
4953// ── Persistent background session ──────────────────────────────────
5054
5155let currentSession : SessionResponse | null = null ;
@@ -57,6 +61,7 @@ async function createSession(): Promise<SessionResponse> {
5761 const res = await fetch ( `${ BASE_URL } /api/session` , { method : "POST" } ) ;
5862 if ( ! res . ok ) throw new Error ( `HTTP ${ res . status } ` ) ;
5963 const session = ( await res . json ( ) ) as SessionResponse ;
64+ session . url = normalizeSessionUrl ( session . url ) ;
6065 currentSession = session ;
6166 sessionCreatedAt = Date . now ( ) ;
6267 return session ;
You can’t perform that action at this time.
0 commit comments