Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit 96aa9b9

Browse files
committed
fix: path先頭に余計な'/'がついて失敗してしまう問題を修正
1 parent 2b7c92f commit 96aa9b9

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ async function fileSearch(url_parse) {
8484
let path_name = url_parse.pathname;
8585

8686
if (path_name.slice(-1) === "/") {
87-
path_name = path_name.slice(0, -1); // remove '/'
87+
path_name = path_name.slice(0, -1); // remove tail '/'
88+
}
89+
90+
if (path_name.slice(0, 1) === "/") {
91+
path_name = path_name.slice(1); // remove head '/'
8892
}
8993

9094
let is_file = false; //file find flg
@@ -96,10 +100,14 @@ async function fileSearch(url_parse) {
96100
if (is_file === false) {
97101
//file not found
98102

99-
if (await checkFileExists(`${path_name}/${DEFAULT_HTML}`)) {
100-
//check defalut html
103+
if (path_name !== "") {
104+
path_name = path_name + "/";
105+
}
106+
107+
if (await checkFileExists(`${path_name}${DEFAULT_HTML}`)) {//check defalut html
108+
101109
is_file = true;
102-
path_name = `${path_name}/${DEFAULT_HTML}`;
110+
path_name = `${path_name}${DEFAULT_HTML}`;
103111
}
104112

105113
if (is_file === false) {

0 commit comments

Comments
 (0)