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

Commit 3e25876

Browse files
committed
fix: error link while subfolder is empty (fix: AlistGo/alist#1356)
1 parent 0db29b5 commit 3e25876

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: src/hooks/useFolderLink.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ const useFolderLink = (proxy = false) => {
77
let { pathname } = useLocation();
88
let host = import.meta.env.VITE_SERVER_URL as string;
99
if (host === "/") {
10-
host = window.location.origin + "/";
10+
host = window.location.origin;
1111
}
1212
let path = pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
1313
if (type === "file") {
1414
path = path.substring(0, path.lastIndexOf("/"));
1515
}
16-
let subfolder = ""
16+
let subfolder = "";
1717
if (window.ALIST.subfolder) {
1818
subfolder = window.ALIST.subfolder;
1919
}
2020
if (subfolder.endsWith("/")) {
2121
subfolder = subfolder.substring(0, subfolder.length - 1);
2222
}
23-
if (subfolder.startsWith("/")) {
24-
subfolder = subfolder.substring(1);
23+
if (!subfolder.startsWith("/")) {
24+
subfolder = "/" + subfolder;
25+
}
26+
if (subfolder === "/") {
27+
subfolder = "";
2528
}
2629
if (proxy) {
2730
return `${host}${subfolder}/p${path}`;

0 commit comments

Comments
 (0)