File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,4 +79,16 @@ describe("hostedPairing", () => {
7979 vi . stubEnv ( "VITE_HTTP_URL" , "https://backend.example.com" ) ;
8080 expect ( isHostedStaticApp ( new URL ( "https://preview.t3.codes/" ) ) ) . toBe ( false ) ;
8181 } ) ;
82+
83+ it ( "detects hosted channel aliases as static apps" , ( ) => {
84+ vi . stubEnv ( "VITE_HOSTED_APP_URL" , "https://app.t3.codes" ) ;
85+ vi . stubEnv ( "VITE_HOSTED_APP_CHANNEL" , "nightly" ) ;
86+ vi . stubEnv ( "VITE_HTTP_URL" , "" ) ;
87+ vi . stubEnv ( "VITE_WS_URL" , "" ) ;
88+
89+ expect ( isHostedStaticApp ( new URL ( "https://nightly.app.t3.codes/" ) ) ) . toBe ( true ) ;
90+
91+ vi . stubEnv ( "VITE_HTTP_URL" , "https://backend.example.com" ) ;
92+ expect ( isHostedStaticApp ( new URL ( "https://nightly.app.t3.codes/" ) ) ) . toBe ( false ) ;
93+ } ) ;
8294} ) ;
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ function configuredBackendUrl(): string {
1818 return import . meta. env . VITE_HTTP_URL ?. trim ( ) || import . meta. env . VITE_WS_URL ?. trim ( ) || "" ;
1919}
2020
21+ function configuredHostedAppChannel ( ) : HostedAppChannel | null {
22+ const channel = import . meta. env . VITE_HOSTED_APP_CHANNEL ?. trim ( ) . toLowerCase ( ) ;
23+ return channel === "latest" || channel === "nightly" ? channel : null ;
24+ }
25+
2126function originFromUrl ( value : string ) : string | null {
2227 try {
2328 return new URL ( value ) . origin ;
@@ -31,6 +36,10 @@ export function isHostedStaticApp(url: URL = new URL(window.location.href)): boo
3136 return false ;
3237 }
3338
39+ if ( configuredHostedAppChannel ( ) ) {
40+ return true ;
41+ }
42+
3443 const hostedOrigin = originFromUrl ( configuredHostedAppUrl ( ) ) ;
3544 return hostedOrigin !== null && url . origin === hostedOrigin ;
3645}
You can’t perform that action at this time.
0 commit comments