fix: #10208, don't use leading slash in directory names

change to use decodeURIComponent in utils.params
isekai-main
Barış Soner Uşaklı 3 years ago
parent 40a0e6dd0b
commit 1d01741ae7

@ -645,10 +645,10 @@
params.forEach(function (param) { params.forEach(function (param) {
const val = param.split('='); const val = param.split('=');
let key = decodeURI(val[0]); let key = decodeURIComponent(val[0]);
const value = ( const value = (
options.disableToType || options.disableToType ||
options.skipToType[key] ? decodeURI(val[1]) : utils.toType(decodeURI(val[1])) options.skipToType[key] ? decodeURIComponent(val[1]) : utils.toType(decodeURIComponent(val[1]))
); );
if (key) { if (key) {

@ -87,15 +87,16 @@ async function filesToData(currentDir, files) {
} }
async function getFileData(currentDir, file) { async function getFileData(currentDir, file) {
const stat = await fs.promises.stat(path.join(currentDir, file)); const pathToFile = path.join(currentDir, file);
const stat = await fs.promises.stat(pathToFile);
let filesInDir = []; let filesInDir = [];
if (stat.isDirectory()) { if (stat.isDirectory()) {
filesInDir = await fs.promises.readdir(path.join(currentDir, file)); filesInDir = await fs.promises.readdir(pathToFile);
} }
const url = `${nconf.get('upload_url') + currentDir.replace(nconf.get('upload_path'), '')}/${file}`; const url = `${nconf.get('upload_url') + currentDir.replace(nconf.get('upload_path'), '')}/${file}`;
return { return {
name: file, name: file,
path: path.join(currentDir, file).replace(nconf.get('upload_path'), ''), path: pathToFile.replace(path.join(nconf.get('upload_path'), '/'), ''),
url: url, url: url,
fileCount: Math.max(0, filesInDir.length - 1), // ignore .gitignore fileCount: Math.max(0, filesInDir.length - 1), // ignore .gitignore
size: stat.size, size: stat.size,

Loading…
Cancel
Save