@@ -25,41 +25,17 @@ 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" ;
32+ const MINIMAL_MODE_OVERRIDE_KEY = "minimal_gitpod_io_mode" ;
3533
3634/**
37- * Check if we should use minimal gitpod.io mode.
38- * Priority:
39- * 1. localStorage override (for testing)
40- * 2. ConfigCat feature flag
35+ * Check if this is production gitpod.io (exact match)
4136 */
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- }
37+ function isProductionGitpodIo ( ) : boolean {
38+ return window . location . hostname === "gitpod.io" ;
6339}
6440
6541/**
@@ -159,15 +135,29 @@ function handleMinimalGitpodIoMode(): void {
159135 window . location . href = `https://www.gitpod.io${ pathname } ${ search } ` ;
160136}
161137
138+ /**
139+ * Extract body content from a full HTML document string.
140+ * This allows keeping the complete HTML structure in the source file for easier editing.
141+ */
142+ function extractBodyContent ( html : string ) : string {
143+ const parser = new DOMParser ( ) ;
144+ const doc = parser . parseFromString ( html , "text/html" ) ;
145+ return doc . body . innerHTML ;
146+ }
147+
162148/**
163149 * Render a minimal static login page without React.
164- * Loads the HTML from an external file for easier review and maintenance .
150+ * Uses innerHTML instead of document.write() to avoid deprecation issues .
165151 */
166152function renderMinimalLoginPage ( ) : void {
167- // Replace the entire document with the minimal login page
168- document . open ( ) ;
169- document . write ( minimalLoginHtml ) ;
170- document . close ( ) ;
153+ const bodyContent = extractBodyContent ( minimalLoginHtml ) ;
154+ const root = document . getElementById ( "root" ) ;
155+ if ( root ) {
156+ root . innerHTML = bodyContent ;
157+ } else {
158+ // Fallback if root doesn't exist
159+ document . body . innerHTML = bodyContent ;
160+ }
171161}
172162
173163/**
@@ -222,22 +212,36 @@ function bootFullApp(): void {
222212
223213/**
224214 * 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
225219 */
226- const bootApp = async ( ) => {
227- // Minimal gitpod.io mode - only on exact "gitpod.io" domain
228- if ( isGitpodIo ( ) ) {
229- const minimalMode = await shouldUseMinimalMode ( ) ;
230-
231- if ( minimalMode ) {
232- handleMinimalGitpodIoMode ( ) ;
233- return ;
234- }
220+ const bootApp = ( ) => {
221+ const pathname = window . location . pathname ;
222+
223+ // Handle website slugs on gitpod.io - redirect to www.gitpod.io
224+ if ( isProductionGitpodIo ( ) && isWebsiteSlug ( pathname ) ) {
225+ window . location . href = `https://www.gitpod.io${ pathname } ${ window . location . search } ` ;
226+ return ;
227+ }
235228
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 ;
229+ // Check if minimal mode should be used
230+ let minimalMode = false ;
231+ try {
232+ if ( localStorage . getItem ( MINIMAL_MODE_OVERRIDE_KEY ) === "true" ) {
233+ minimalMode = true ;
240234 }
235+ } catch {
236+ // localStorage might not be available
237+ }
238+ if ( ! minimalMode && isProductionGitpodIo ( ) ) {
239+ minimalMode = true ;
240+ }
241+
242+ if ( minimalMode ) {
243+ handleMinimalGitpodIoMode ( ) ;
244+ return ;
241245 }
242246
243247 // Boot full React app
0 commit comments