修复openlist目录包含文件时扫描失败
This commit is contained in:
@@ -14,11 +14,18 @@ export const runtime = 'nodejs';
|
|||||||
*/
|
*/
|
||||||
function cleanPath(path: string): string {
|
function cleanPath(path: string): string {
|
||||||
// 移除 UTF-8 BOM (U+FEFF) 和其他零宽度字符
|
// 移除 UTF-8 BOM (U+FEFF) 和其他零宽度字符
|
||||||
return path
|
let cleaned = path
|
||||||
.replace(/^\uFEFF/, '') // 移除开头的 BOM
|
.replace(/^\uFEFF/, '') // 移除开头的 BOM
|
||||||
.replace(/\uFEFF/g, '') // 移除所有 BOM
|
.replace(/\uFEFF/g, '') // 移除所有 BOM
|
||||||
.replace(/[\u200B-\u200D\uFEFF]/g, '') // 移除零宽度字符
|
.replace(/[\u200B-\u200D\uFEFF]/g, '') // 移除零宽度字符
|
||||||
.trim(); // 移除首尾空白
|
.trim(); // 移除首尾空白
|
||||||
|
|
||||||
|
// 移除末尾的 /(除非路径就是 /)
|
||||||
|
if (cleaned.length > 1 && cleaned.endsWith('/')) {
|
||||||
|
cleaned = cleaned.slice(0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cleaned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -254,7 +254,8 @@ async function performScan(
|
|||||||
const pageFolders = listResponse.data.content.filter((item) => item.is_dir);
|
const pageFolders = listResponse.data.content.filter((item) => item.is_dir);
|
||||||
folders.push(...pageFolders);
|
folders.push(...pageFolders);
|
||||||
|
|
||||||
if (folders.length >= total) {
|
// 判断是否还有更多数据:当前页为 null 或数据量小于 pageSize 说明已经是最后一页
|
||||||
|
if (!listResponse.data.content || listResponse.data.content.length < pageSize) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user