Removed adding base_url since it is perfectly handled by browsers. And it reduces size of a page.
This commit is contained in:
parent
8e36ac8439
commit
f728f4de4f
8
files.js
8
files.js
@ -54,7 +54,7 @@ async function fileType(name) {
|
|||||||
return "octet-stream";
|
return "octet-stream";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDirectoryList(dir_path, base_url) {
|
async function getDirectoryList(dir_path) {
|
||||||
let dirs = [];
|
let dirs = [];
|
||||||
let files = [];
|
let files = [];
|
||||||
let total_files_size = 0;
|
let total_files_size = 0;
|
||||||
@ -65,7 +65,7 @@ async function getDirectoryList(dir_path, base_url) {
|
|||||||
if (stat.isDirectory())
|
if (stat.isDirectory())
|
||||||
dirs.push({
|
dirs.push({
|
||||||
name: dirent.name,
|
name: dirent.name,
|
||||||
link: `${base_url}${encodeURIComponent(dirent.name)}/`,
|
link: `${encodeURIComponent(dirent.name)}/`,
|
||||||
datetime: util.datetime(stat.mtime, util.formats.file_date),
|
datetime: util.datetime(stat.mtime, util.formats.file_date),
|
||||||
size: "DIR",
|
size: "DIR",
|
||||||
size_unit: '' });
|
size_unit: '' });
|
||||||
@ -73,7 +73,7 @@ async function getDirectoryList(dir_path, base_url) {
|
|||||||
total_files_size += stat.size;
|
total_files_size += stat.size;
|
||||||
files.push({
|
files.push({
|
||||||
name: dirent.name,
|
name: dirent.name,
|
||||||
link: `${base_url}${encodeURIComponent(dirent.name)}`,
|
link: `${encodeURIComponent(dirent.name)}`,
|
||||||
datetime: util.datetime(stat.mtime, util.formats.file_date),
|
datetime: util.datetime(stat.mtime, util.formats.file_date),
|
||||||
size: +s,
|
size: +s,
|
||||||
size_unit: u });
|
size_unit: u });
|
||||||
@ -93,7 +93,7 @@ function setRoutes(router) {
|
|||||||
let stat = fs.lstatSync(file_path);
|
let stat = fs.lstatSync(file_path);
|
||||||
if (stat.isDirectory()) {
|
if (stat.isDirectory()) {
|
||||||
const [items, total_directories, total_files, total_files_size]
|
const [items, total_directories, total_files, total_files_size]
|
||||||
= await getDirectoryList(file_path, ctx.originalUrl);
|
= await getDirectoryList(file_path);
|
||||||
await ctx.render('index', {
|
await ctx.render('index', {
|
||||||
title: "/ Files",
|
title: "/ Files",
|
||||||
description: "File share.",
|
description: "File share.",
|
||||||
|
Loading…
Reference in New Issue
Block a user