@@ -27,7 +27,7 @@ function childrenLoader(sidebarEl: HTMLElement) {
2727 const fileTree = sidebarEl . querySelector ( '#view-file-tree' ) ;
2828 const apiBaseUrl = fileTree . getAttribute ( 'data-api-base-url' ) ;
2929 const refTypeNameSubURL = fileTree . getAttribute ( 'data-current-ref-type-name-sub-url' ) ;
30- const response = await GET ( `${ apiBaseUrl } /tree/${ refTypeNameSubURL } /${ encodeURIComponent ( path ?? '' ) } ?recursive=${ recursive ?? false } ` ) ;
30+ const response = await GET ( encodeURI ( `${ apiBaseUrl } /tree/${ refTypeNameSubURL } /${ path ?? '' } ?recursive=${ recursive ?? false } ` ) ) ;
3131 const json = await response . json ( ) ;
3232 if ( json instanceof Array ) {
3333 return json . map ( ( i ) => ( {
@@ -78,8 +78,8 @@ export function initViewFileTreeSidebar() {
7878
7979 fileTree . classList . remove ( 'is-loading' ) ;
8080 const fileTreeView = createApp ( ViewFileTree , { files, selectedItem, loadChildren : childrenLoader ( el ) , loadContent : ( path : string ) => {
81- selectedItem . value = getSelectedPath ( refString , `${ baseUrl } /src${ refString } /${ path } ` ) ;
82- window . history . pushState ( null , null , ` ${ baseUrl } /src ${ refString } / ${ encodeURIComponent ( path ) } ` ) ;
81+ window . history . pushState ( null , null , encodeURI ( `${ baseUrl } /src${ refString } /${ path } ` ) ) ;
82+ selectedItem . value = path ;
8383 loadContent ( el ) ;
8484 } } ) ;
8585 fileTreeView . mount ( fileTree ) ;
@@ -94,7 +94,7 @@ export function initViewFileTreeSidebar() {
9494 } ) ;
9595}
9696
97- function getSelectedPath ( ref : string , url ?: string ) {
98- const path = url ?? ( new URL ( window . location . href ) . pathname ) ;
97+ function getSelectedPath ( ref : string ) {
98+ const path = decodeURI ( new URL ( window . location . href ) . pathname ) ;
9999 return path . substring ( path . indexOf ( ref ) + ref . length + 1 ) ;
100100}
0 commit comments