Removed adding base_url since it is perfectly handled by browsers. And it reduces size of a page.

This commit is contained in:
Alexander Andreev 2021-02-17 02:05:54 +04:00
parent 8e36ac8439
commit f728f4de4f
Signed by: Arav
GPG Key ID: 610DF2574456329F

View File

@ -54,7 +54,7 @@ async function fileType(name) {
return "octet-stream";
}
async function getDirectoryList(dir_path, base_url) {
async function getDirectoryList(dir_path) {
let dirs = [];
let files = [];
let total_files_size = 0;
@ -65,7 +65,7 @@ async function getDirectoryList(dir_path, base_url) {
if (stat.isDirectory())
dirs.push({
name: dirent.name,
link: `${base_url}${encodeURIComponent(dirent.name)}/`,
link: `${encodeURIComponent(dirent.name)}/`,
datetime: util.datetime(stat.mtime, util.formats.file_date),
size: "DIR",
size_unit: '' });
@ -73,7 +73,7 @@ async function getDirectoryList(dir_path, base_url) {
total_files_size += stat.size;
files.push({
name: dirent.name,
link: `${base_url}${encodeURIComponent(dirent.name)}`,
link: `${encodeURIComponent(dirent.name)}`,
datetime: util.datetime(stat.mtime, util.formats.file_date),
size: +s,
size_unit: u });
@ -93,7 +93,7 @@ function setRoutes(router) {
let stat = fs.lstatSync(file_path);
if (stat.isDirectory()) {
const [items, total_directories, total_files, total_files_size]
= await getDirectoryList(file_path, ctx.originalUrl);
= await getDirectoryList(file_path);
await ctx.render('index', {
title: "/ Files",
description: "File share.",