@@ -70,7 +70,7 @@ import {
7070import {
7171 parseCurrentUrl ,
7272 navigateToVersion ,
73- getAssetBasePath ,
73+ getDeployBase ,
7474 MINOR_VERSION_REGEX
7575} from '../navigationUtils'
7676
@@ -136,7 +136,7 @@ class App extends Component<AppProps, AppState> {
136136 }
137137
138138 getDocsBasePath = ( ) => {
139- const base = getAssetBasePath ( )
139+ const base = getDeployBase ( )
140140 const { selectedMinorVersion } = this . state
141141 if ( selectedMinorVersion ) {
142142 return `${ base } /docs/${ selectedMinorVersion } /`
@@ -212,13 +212,13 @@ class App extends Component<AppProps, AppState> {
212212 navigateToVersion ( newVersion )
213213
214214 this . fetchMainDocsData (
215- `${ getAssetBasePath ( ) } /docs/${ newVersion } /markdown-and-sources-data.json` ,
215+ `${ getDeployBase ( ) } /docs/${ newVersion } /markdown-and-sources-data.json` ,
216216 signal
217217 ) . catch ( errorHandler )
218218
219219 // Icons are not version-specific; only re-fetch if not already loaded
220220 if ( ! this . state . legacyIconsData ) {
221- fetch ( `${ getAssetBasePath ( ) } /legacy-icons-data.json` , { signal } )
221+ fetch ( `${ getDeployBase ( ) } /legacy-icons-data.json` , { signal } )
222222 . then ( ( response ) => response . json ( ) )
223223 . then ( ( legacyIconsData ) => {
224224 this . setState ( { legacyIconsData } )
@@ -282,7 +282,7 @@ class App extends Component<AppProps, AppState> {
282282 this . fetchVersionData ( signal ) . catch ( errorHandler )
283283 document . addEventListener ( 'keydown' , this . handleTabKey )
284284
285- fetch ( `${ getAssetBasePath ( ) } /legacy-icons-data.json` , { signal } )
285+ fetch ( `${ getDeployBase ( ) } /legacy-icons-data.json` , { signal } )
286286 . then ( ( response ) => response . json ( ) )
287287 . then ( ( iconsData ) => this . setState ( { legacyIconsData : iconsData } ) )
288288 . catch ( errorHandler )
@@ -304,13 +304,13 @@ class App extends Component<AppProps, AppState> {
304304 selectedMinorVersion
305305 } )
306306 return this . fetchMainDocsData (
307- `${ getAssetBasePath ( ) } /docs/${ selectedMinorVersion } /markdown-and-sources-data.json` ,
307+ `${ getDeployBase ( ) } /docs/${ selectedMinorVersion } /markdown-and-sources-data.json` ,
308308 signal
309309 )
310310 }
311311 // No minor versions available, fetch from root path
312312 return this . fetchMainDocsData (
313- `${ getAssetBasePath ( ) } /markdown-and-sources-data.json` ,
313+ `${ getDeployBase ( ) } /markdown-and-sources-data.json` ,
314314 signal
315315 )
316316 } )
@@ -360,23 +360,21 @@ class App extends Component<AppProps, AppState> {
360360 getPathInfo = ( ) => {
361361 const { hash, pathname } = window . location
362362
363- const cleanPath = pathname . replace ( / ^ \/ + | \/ + $ / g, '' )
364- const segments = cleanPath . split ( '/' ) . filter ( Boolean )
365-
366- // Skip PR preview prefix
367- let idx = 0
363+ // Strip the deploy base (e.g. '/latest', '/pr-preview/pr-123',
364+ // '/<repo>/pr-preview/pr-N') before parsing app segments.
365+ const deployBase = getDeployBase ( )
366+ let rest = pathname
368367 if (
369- segments . length >= 2 &&
370- segments [ 0 ] === 'pr-preview' &&
371- segments [ 1 ] . startsWith ( 'pr-' )
368+ deployBase &&
369+ ( rest === deployBase || rest . startsWith ( deployBase + '/' ) )
372370 ) {
373- idx = 2
371+ rest = rest . slice ( deployBase . length )
374372 }
375373
376- // Skip /latest/ prefix
377- if ( idx === 0 && segments [ idx ] === 'latest' ) {
378- idx ++
379- }
374+ const cleanPath = rest . replace ( / ^ \/ + | \/ + $ / g , '' )
375+ const segments = cleanPath . split ( '/' ) . filter ( Boolean )
376+
377+ let idx = 0
380378
381379 // Skip minor version prefix (e.g. v11_7)
382380 if ( idx < segments . length && MINOR_VERSION_REGEX . test ( segments [ idx ] ) ) {
0 commit comments