@@ -313,9 +313,17 @@ define([
313313 // if it's outside of notebookPath, ignore notebookPath
314314 var prevLength = notebookPathStrLength ;
315315 var useSidebar = false ;
316- if ( currentRelativePathStrArray . includes ( '..' ) ) {
317- prevLength = 0 ;
318- useSidebar = true ;
316+ if ( currentRelativePathStr . includes ( '..' ) ) {
317+ var upperList = currentRelativePathStr . match ( / ( \. \. \/ ) / g) ;
318+ if ( upperList && upperList . length > 0 ) {
319+ // in case, currentRelativePathStr = ../../somePathHere
320+ prevLength -= upperList . length * 3 ; // 3 = length of '../' upper path string
321+ useSidebar = true ;
322+ } else {
323+ // in case, currentRelativePathStr = ..
324+ prevLength = 0 ;
325+ useSidebar = true ;
326+ }
319327 }
320328 let slashStr = '/' ;
321329 currentRelativePathStrArray . forEach ( ( pathToken , index ) => {
@@ -447,54 +455,7 @@ define([
447455 var fileNavigationState = this . pathState ;
448456
449457 var baseFolder = fileNavigationState . baseFolder ;
450- var baseDirStr = fileNavigationState . baseDir ;
451- var noteBookPathStr = fileNavigationState . notebookPath ;
452458 var currentDirStr = fileNavigationState . currentPath ;
453- var noteBookPathStrLength = noteBookPathStr . length ;
454-
455- var baseDirStrLength = baseDirStr . length ;
456-
457- /** upDirectoryCount:
458- * count how many times went up to the parent path, since file navigation opened
459- */
460- var upDirectoryCount = 0 ;
461- var _upDirectoryCount = 0 ;
462-
463- var splitedNoteBookPathStrArray = noteBookPathStr . split ( '/' ) ;
464- var splitedBaseDirArray = baseDirStr . split ( '/' ) ;
465- var splitedCurrentDirArray = currentDirStr . split ( '/' ) ;
466-
467- var relativeBaseDirArray = splitedBaseDirArray . slice ( splitedNoteBookPathStrArray . length , splitedBaseDirArray . length ) ;
468- var relativeCurrentDirArray = splitedCurrentDirArray . slice ( splitedNoteBookPathStrArray . length , splitedCurrentDirArray . length ) ;
469-
470- /**
471- * compare base path and notebook path, increase upDirectoryCount
472- */
473- var _baseDirStrLength = baseDirStrLength ;
474- while ( noteBookPathStrLength < _baseDirStrLength ) {
475- _baseDirStrLength -- ;
476- if ( baseDirStr [ _baseDirStrLength ] === '/' ) {
477- upDirectoryCount += 1 ;
478- }
479- }
480-
481- /**
482- * Compare notebook path and current relative path, decrease upDirectoryCount
483- */
484- relativeCurrentDirArray . forEach ( ( forderName , index ) => {
485- if ( forderName === relativeBaseDirArray [ index ] ) {
486- upDirectoryCount -= 1 ;
487- }
488- } ) ;
489-
490- /**
491- * Add ../ based on upDirectoryCount
492- */
493- _upDirectoryCount = upDirectoryCount ;
494- var prefixUpDirectory = `` ;
495- while ( _upDirectoryCount -- > 0 ) {
496- prefixUpDirectory += `../` ;
497- }
498459
499460 var slashstr = `/` ;
500461 if ( relativeDirPath === '' ) {
@@ -504,10 +465,9 @@ define([
504465 var pathInput = '' ;
505466 var fileInput = `${ filePathStr } ` ;
506467 // if baseFolder doesn't exist in current path
507- if ( upDirectoryCount > 0
508- && currentDirStr . indexOf ( baseFolder ) === - 1 ) {
468+ if ( currentDirStr . indexOf ( baseFolder ) === - 1 ) {
509469
510- pathInput = `${ prefixUpDirectory } ${ relativeDirPath } ${ slashstr } ${ filePathStr } ` ;
470+ pathInput = `${ relativeDirPath } ${ slashstr } ${ filePathStr } ` ;
511471 } else {
512472 // if baseFolder exists in current path
513473 pathInput = `./${ relativeDirPath } ${ slashstr } ${ filePathStr } ` ;
0 commit comments