diff --git a/src/routes/viewer.ts b/src/routes/viewer.ts index 351ae394..b841689f 100644 --- a/src/routes/viewer.ts +++ b/src/routes/viewer.ts @@ -1,11 +1,11 @@ import { lstatSync, readFileSync } from 'fs'; -import { dirname as pdirname, basename as pbasename, join as pjoin } from 'path'; +import { dirname as pdirname, join as pjoin } from 'path'; import { Request, Response, Router } from 'express'; import { messageClientsAt } from '../app'; import config from '../parser/config'; -import { pathToURL, pcomponents, pmime } from '../utils/path'; +import { pathToURL, pcomponents, pmime, getParentName } from '../utils/path'; import { renderDirectory, renderTextFile } from '../parser/parser'; export const router = Router(); @@ -22,14 +22,6 @@ const pageTitle = (path: string) => { } else return pjoin(...comps.slice(-2)); }; -const dirParent = (path: string) => { - let parent = pbasename(pdirname(path)); - if (!parent) { - parent = '/ (root)'; - } - return parent; -}; - router.get(/.*/, async (req: Request, res: Response) => { const path = res.locals.filepath; @@ -75,7 +67,7 @@ router.get(/.*/, async (req: Request, res: Response) => { ${config.styles}
- +