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

Commit

Permalink
fix: error link while subfolder is empty (fix: AlistGo/alist#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jul 21, 2022
1 parent 0db29b5 commit 86fbb61
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/hooks/useFolderLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ const useFolderLink = (proxy = false) => {
let { pathname } = useLocation();
let host = import.meta.env.VITE_SERVER_URL as string;
if (host === "/") {
host = window.location.origin + "/";
host = window.location.origin;
}
let path = pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
if (type === "file") {
path = path.substring(0, path.lastIndexOf("/"));
}
let subfolder = ""
let subfolder = "";
if (window.ALIST.subfolder) {
subfolder = window.ALIST.subfolder;
}
if (subfolder.endsWith("/")) {
subfolder = subfolder.substring(0, subfolder.length - 1);
}
if (subfolder.startsWith("/")) {
subfolder = subfolder.substring(1);
if (!subfolder.startsWith("/")) {
subfolder = "/" + subfolder;
}
if (proxy) {
return `${host}${subfolder}/p${path}`;
Expand Down

0 comments on commit 86fbb61

Please sign in to comment.