buddhism/utils/pathUtils.js
WindowBird 1b2dae6e8c 引入设备录入功能,解决脚本依赖循环问题;
× Found 1 circular dependency!

1) components/blufi/xBlufi-wx-impl.js > components/blufi/xBlufi.js
2025-09-23 17:13:16 +08:00

22 lines
422 B
JavaScript

// utils/pathUtils.js
const path = require("path");
let normalizeCount = 0;
const MAX_NORMALIZE_DEPTH = 20;
export function safeNormalize(p) {
if (normalizeCount++ > MAX_NORMALIZE_DEPTH) {
console.error("[Path Normalize] Maximum depth reached:", p);
return p;
}
try {
return path
.normalize(p)
.replace(/\\/g, "/")
.replace(/\/{2,}/g, "/");
} finally {
normalizeCount--;
}
}