@@ -777,7 +777,7 @@ async function getDirectoryListing(req) {
777777 } )
778778 ) ;
779779 const filteredFiles = files . filter ( ( f ) => f !== null ) ;
780- await getSelectedPage ( req , filteredFiles ) ;
780+ await getSelectedPage ( req , files ) ;
781781 let r = await getDirectoryListingInternal ( req , filteredFiles , [ ] ) ;
782782 if ( filteredFiles [ filteredFiles . length - 1 ] . folders . length > 0 ) {
783783 r += `</div></div>` ;
@@ -788,7 +788,14 @@ async function getDirectoryListing(req) {
788788async function getSelectedPage ( req , files ) {
789789 // console.log("getSelectedPage", req);
790790 console . log ( "getSelectedPage" , files ) ;
791- console . log ( 'parsedOriginalUrl' , req . _parsedUrl . path ) ;
791+ let path = req . _parsedUrl . path ;
792+ if ( path . startsWith ( "/md/" ) ) {
793+ path = path . slice ( 4 ) ;
794+ }
795+ while ( path . startsWith ( "/" ) ) {
796+ path = path . slice ( 1 ) ;
797+ }
798+ console . log ( 'parsedOriginalUrl' , path ) ;
792799}
793800
794801async function getDirectoryListingInternal ( req , files , folders ) {
@@ -807,7 +814,7 @@ async function getDirectoryListingInternal(req, files, folders) {
807814 html += `</div></div>` ;
808815 }
809816 }
810- // Open as many folders as needed to reach the new folder
817+ // Insert as many folders as needed to reach the new folder
811818 for ( let j = diffIndex ; j < file . folderArray . length ; j ++ ) {
812819 const folder = file . folderArray [ j ] ;
813820 html += insertDirFolder ( folder , j ) ;
0 commit comments