@@ -70,14 +70,6 @@ function addProjectI18NOptions(
7070 return ;
7171 }
7272
73- const mainOptions = findPropertyInAstObject ( browserConfig , 'options' ) ;
74- const mainBaseHref =
75- mainOptions &&
76- mainOptions . kind === 'object' &&
77- findPropertyInAstObject ( mainOptions , 'baseHref' ) ;
78- const hasMainBaseHref =
79- ! ! mainBaseHref && mainBaseHref . kind === 'string' && mainBaseHref . value !== '/' ;
80-
8173 // browser builder options
8274 let locales : Record < string , string | { translation : string ; baseHref : string } > | undefined ;
8375 const options = getAllOptions ( browserConfig ) ;
@@ -97,9 +89,7 @@ function addProjectI18NOptions(
9789
9890 const baseHref = findPropertyInAstObject ( option , 'baseHref' ) ;
9991 let baseHrefValue ;
100- // if the main options has a non-default base href, the i18n configuration
101- // for the locale baseHref is disabled to more obviously mimic existing behavior
102- if ( baseHref && ! hasMainBaseHref ) {
92+ if ( baseHref ) {
10393 if ( baseHref . kind === 'string' && baseHref . value !== `/${ localIdValue } /` ) {
10494 baseHrefValue = baseHref . value ;
10595 }
@@ -187,11 +177,15 @@ function addBuilderI18NOptions(recorder: UpdateRecorder, builderConfig: JsonAstO
187177 }
188178
189179 // localize base HREF values are controlled by the i18n configuration
190- // except if the main options has a non-default base href, the i18n configuration
191- // for the locale baseHref is disabled in that case to more obviously mimic existing behavior
192180 const baseHref = findPropertyInAstObject ( option , 'baseHref' ) ;
193- if ( localeId && i18nFile && baseHref && ! hasMainBaseHref ) {
181+ if ( localeId && i18nFile && baseHref ) {
194182 removePropertyInAstObject ( recorder , option , 'baseHref' ) ;
183+
184+ // if the main option set has a non-default base href,
185+ // ensure that the augmented base href has the correct base value
186+ if ( hasMainBaseHref ) {
187+ insertPropertyInAstObjectInOrder ( recorder , option , 'baseHref' , '/' , 12 ) ;
188+ }
195189 }
196190 }
197191}
0 commit comments