From dbe4f515d7bdfc6c96b5de8d2b760fad1b315a70 Mon Sep 17 00:00:00 2001 From: Tobias Wild <46871747+tobiaswild@users.noreply.github.com> Date: Tue, 25 Mar 2025 17:53:28 +0100 Subject: [PATCH] fix root dir back link error --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 564f012..dcca900 100644 --- a/src/index.js +++ b/src/index.js @@ -393,7 +393,9 @@ const renderDirectory = async (current, acceptsJSON, handlers, methods, config, const toRoot = path.relative(current, absolutePath); const directory = path.join(path.basename(current), toRoot, slashSuffix); - const pathParts = directory.split(path.sep).filter(Boolean); + const pathParts = current === '/' + ? ['', ...directory.split(path.sep).filter(Boolean)] + : directory.split(path.sep).filter(Boolean); // Sort to list directories first, then sort alphabetically files = files.sort((a, b) => {