diff --git a/assets/index.js b/assets/index.js
index 9a4983a..3a87e11 100644
--- a/assets/index.js
+++ b/assets/index.js
@@ -55,7 +55,6 @@ class Uploader {
upload() {
const { idx, name } = this;
const url = getUrl(name);
- const encodedUrl = encodedStr(url);
const encodedName = encodedStr(name);
$uploadersTable.insertAdjacentHTML("beforeend", `
@@ -63,7 +62,7 @@ class Uploader {
${getSvg()}
- ${encodedName}
+ ${encodedName}
|
|
`);
@@ -160,16 +159,15 @@ function addBreadcrumb(href, uri_prefix) {
if (!path.endsWith("/")) {
path += "/";
}
- path += encodeURI(name);
+ path += encodeURIComponent(name);
}
- const encodedPath = encodedStr(path);
const encodedName = encodedStr(name);
if (i === 0) {
- $breadcrumb.insertAdjacentHTML("beforeend", ``);
+ $breadcrumb.insertAdjacentHTML("beforeend", ``);
} else if (i === len - 1) {
$breadcrumb.insertAdjacentHTML("beforeend", `${encodedName}`);
} else {
- $breadcrumb.insertAdjacentHTML("beforeend", `${encodedName}`);
+ $breadcrumb.insertAdjacentHTML("beforeend", `${encodedName}`);
}
if (i !== len - 1) {
$breadcrumb.insertAdjacentHTML("beforeend", `/`);
@@ -185,23 +183,21 @@ function addBreadcrumb(href, uri_prefix) {
function addPath(file, index) {
const encodedName = encodedStr(file.name);
let url = getUrl(file.name)
- let encodedUrl = encodedStr(url);
let actionDelete = "";
let actionDownload = "";
let actionMove = "";
if (file.path_type.endsWith("Dir")) {
url += "/";
- encodedUrl += "/";
actionDownload = `
`;
} else {
actionDownload = `
`;
@@ -231,7 +227,7 @@ function addPath(file, index) {
${getSvg(file.path_type)}
- ${encodedName}
+ ${encodedName}
|
${formatMtime(file.mtime)} |
${formatSize(file.size).join(" ")} |
@@ -287,12 +283,14 @@ async function movePath(index) {
const filePath = decodeURIComponent(fileUrlObj.pathname.slice(prefix.length));
- const newPath = prompt("Enter new path", filePath)
- if (!newPath || filePath === newPath) return;
- const newFileUrl = fileUrlObj.origin + prefix + encodeURI(newPath);
+ let newPath = prompt("Enter new path", filePath)
+ if (!newPath) return;
+ if (!newPath.startsWith("/")) newPath = "/" + newPath;
+ if (filePath === newPath) return;
+ const newFileUrl = fileUrlObj.origin + prefix + newPath.split("/").map(encodeURIComponent).join("/");
try {
- const res = await fetch(getUrl(file.name), {
+ const res = await fetch(fileUrl, {
method: "MOVE",
headers: {
"Destination": newFileUrl,
@@ -367,7 +365,7 @@ async function addFileEntries(entries, dirs) {
function getUrl(name) {
let url = location.href.split('?')[0];
if (!url.endsWith("/")) url += "/";
- url += encodeURI(name);
+ url += name.split("/").map(encodeURIComponent).join("/");
return url;
}