@@ -25,42 +25,11 @@ import "./index.css";
2525import { PaymentContextProvider } from "./payment-context" ;
2626import { ThemeContextProvider } from "./theme-context" ;
2727import { UserContextProvider } from "./user-context" ;
28- import { getURLHash , isGitpodIo , isWebsiteSlug } from "./utils" ;
29- import { getExperimentsClient } from "./experiments/client" ;
28+ import { getURLHash , isWebsiteSlug } from "./utils" ;
3029// Import the minimal login HTML template at build time
3130import minimalLoginHtml from "./minimal-login.html" ;
3231
33- const MINIMAL_MODE_STORAGE_KEY = "minimal_gitpod_io_mode" ;
34- const MINIMAL_MODE_FLAG_NAME = "minimal_gitpod_io_mode" ;
35-
36- /**
37- * Check if we should use minimal gitpod.io mode.
38- * Priority:
39- * 1. localStorage override (for testing)
40- * 2. ConfigCat feature flag
41- */
42- async function shouldUseMinimalMode ( ) : Promise < boolean > {
43- // Check localStorage override first (sync, for testing)
44- try {
45- const localOverride = localStorage . getItem ( MINIMAL_MODE_STORAGE_KEY ) ;
46- if ( localOverride === "true" ) return true ;
47- if ( localOverride === "false" ) return false ;
48- } catch {
49- // localStorage might not be available
50- }
51-
52- // Check ConfigCat feature flag
53- try {
54- const client = getExperimentsClient ( ) ;
55- const value = await client . getValueAsync ( MINIMAL_MODE_FLAG_NAME , false , {
56- gitpodHost : window . location . host ,
57- } ) ;
58- return value === true ;
59- } catch ( error ) {
60- console . error ( "Failed to check minimal mode flag:" , error ) ;
61- return false ; // Fail safe: use full app
62- }
63- }
32+ const MINIMAL_MODE_OVERRIDE_KEY = "minimal_gitpod_io_mode" ;
6433
6534/**
6635 * Check if the pathname is a known app route that should show the minimal login page
@@ -159,15 +128,29 @@ function handleMinimalGitpodIoMode(): void {
159128 window . location . href = `https://www.gitpod.io${ pathname } ${ search } ` ;
160129}
161130
131+ /**
132+ * Extract body content from a full HTML document string.
133+ * This allows keeping the complete HTML structure in the source file for easier editing.
134+ */
135+ function extractBodyContent ( html : string ) : string {
136+ const parser = new DOMParser ( ) ;
137+ const doc = parser . parseFromString ( html , "text/html" ) ;
138+ return doc . body . innerHTML ;
139+ }
140+
162141/**
163142 * Render a minimal static login page without React.
164- * Loads the HTML from an external file for easier review and maintenance .
143+ * Uses innerHTML instead of document.write() to avoid deprecation issues .
165144 */
166145function renderMinimalLoginPage ( ) : void {
167- // Replace the entire document with the minimal login page
168- document . open ( ) ;
169- document . write ( minimalLoginHtml ) ;
170- document . close ( ) ;
146+ const bodyContent = extractBodyContent ( minimalLoginHtml ) ;
147+ const root = document . getElementById ( "root" ) ;
148+ if ( root ) {
149+ root . innerHTML = bodyContent ;
150+ } else {
151+ // Fallback if root doesn't exist
152+ document . body . innerHTML = bodyContent ;
153+ }
171154}
172155
173156/**
@@ -221,23 +204,44 @@ function bootFullApp(): void {
221204}
222205
223206/**
224- * Main boot function
207+ * Check if this is exactlly gitpod.io
225208 */
226- const bootApp = async ( ) => {
227- // Minimal gitpod.io mode - only on exact "gitpod.io" domain
228- if ( isGitpodIo ( ) ) {
229- const minimalMode = await shouldUseMinimalMode ( ) ;
209+ function isExactGitpodIo ( ) : boolean {
210+ return window . location . hostname === "gitpod.io" ;
211+ }
230212
231- if ( minimalMode ) {
232- handleMinimalGitpodIoMode ( ) ;
213+ /**
214+ * Main boot function
215+ *
216+ * Minimal mode is enabled when:
217+ * - localStorage override is "true" (for testing in preview environments)
218+ * - Host is exactly "gitpod.io" AND path is not a website slug
219+ */
220+ const bootApp = ( ) => {
221+ let minimalMode = false ;
222+
223+ // Handle website slugs on gitpod.io - redirect to www.gitpod.io
224+ if ( isExactGitpodIo ( ) ) {
225+ const pathname = window . location . pathname ;
226+ if ( isWebsiteSlug ( pathname ) ) {
227+ window . location . href = `https://www.gitpod.io${ pathname } ${ window . location . search } ` ;
233228 return ;
234229 }
230+ minimalMode = true ;
231+ }
235232
236- // Not in minimal mode, but still handle website slugs
237- if ( isWebsiteSlug ( window . location . pathname ) ) {
238- window . location . host = "www.gitpod.io" ;
239- return ;
233+ // Check local storage override
234+ try {
235+ if ( localStorage . getItem ( MINIMAL_MODE_OVERRIDE_KEY ) === "true" ) {
236+ minimalMode = true ;
240237 }
238+ } catch {
239+ // localStorage might not be available
240+ }
241+
242+ if ( minimalMode ) {
243+ handleMinimalGitpodIoMode ( ) ;
244+ return ;
241245 }
242246
243247 // Boot full React app
0 commit comments