From bf51267b920b364f7846f2ab57094cf67d98a121 Mon Sep 17 00:00:00 2001 From: sym <849228735@qq.com> Date: Sat, 5 Jun 2021 01:35:07 +0800 Subject: [PATCH] fix 404 when file name contains hashtags --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 05e3430..9955537 100644 --- a/src/index.js +++ b/src/index.js @@ -358,7 +358,9 @@ const renderDirectory = async (current, acceptsJSON, handlers, methods, config, stats = await handlers.lstat(filePath); } - details.relative = path.join(relativePath, details.base); + const rawRelativePath = path.join(relativePath, details.base); + // fix 404 when file name contains hashtags + details.relative = rawRelativePath.replace(/#/g, '%23'); if (stats.isDirectory()) { details.base += slashSuffix;