@@ -144,12 +144,8 @@ class GameManager {
144144
145145 async loadStrategyCode ( strategyName ) {
146146 try {
147- const currentUrl = new URL ( window . location . href ) ;
148- const basePath = currentUrl . pathname . endsWith ( '/' ) ? currentUrl . pathname : currentUrl . pathname . substring ( 0 , currentUrl . pathname . lastIndexOf ( '/' ) + 1 ) ;
149- const baseUrl = currentUrl . origin + basePath ;
150- const response = await fetch (
151- `${ baseUrl } strategies/${ strategyName } .dsl`
152- ) ;
147+ const strategiesUrl = new URL ( `strategies/${ strategyName } .dsl` , window . location . href ) . href ;
148+ const response = await fetch ( strategiesUrl ) ;
153149 const code = await response . text ( ) ;
154150 this . strategyCodeTextarea . value = code ;
155151 } catch ( error ) {
@@ -168,11 +164,9 @@ class GameManager {
168164 { type : 'module' }
169165 ) ;
170166
171- // Calculate base URL that includes subpath for production
172- // Extract directory from current URL to ensure we get the subpath
173- const currentUrl = new URL ( window . location . href ) ;
174- const basePath = currentUrl . pathname . endsWith ( '/' ) ? currentUrl . pathname : currentUrl . pathname . substring ( 0 , currentUrl . pathname . lastIndexOf ( '/' ) + 1 ) ;
175- const baseUrl = currentUrl . origin + basePath ;
167+ // Calculate base URL using URL constructor for proper relative resolution
168+ // This will correctly handle both dev and prod environments
169+ const baseUrl = new URL ( './' , window . location . href ) . href ;
176170
177171 // Pass strategy name and base URL to worker
178172 this . aiWorker . postMessage ( {
0 commit comments