@@ -70,14 +70,6 @@ function addProjectI18NOptions(
70
70
return ;
71
71
}
72
72
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
-
81
73
// browser builder options
82
74
let locales : Record < string , string | { translation : string ; baseHref : string } > | undefined ;
83
75
const options = getAllOptions ( browserConfig ) ;
@@ -97,9 +89,7 @@ function addProjectI18NOptions(
97
89
98
90
const baseHref = findPropertyInAstObject ( option , 'baseHref' ) ;
99
91
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 ) {
103
93
if ( baseHref . kind === 'string' && baseHref . value !== `/${ localIdValue } /` ) {
104
94
baseHrefValue = baseHref . value ;
105
95
}
@@ -187,11 +177,15 @@ function addBuilderI18NOptions(recorder: UpdateRecorder, builderConfig: JsonAstO
187
177
}
188
178
189
179
// 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
192
180
const baseHref = findPropertyInAstObject ( option , 'baseHref' ) ;
193
- if ( localeId && i18nFile && baseHref && ! hasMainBaseHref ) {
181
+ if ( localeId && i18nFile && baseHref ) {
194
182
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
+ }
195
189
}
196
190
}
197
191
}
0 commit comments