fix(PathUtils): Improve cross-platform absolute path detection
Replace complex heuristic with precise pattern matching for absolute paths: - Unix paths: starts with / - Windows drive letters: C:\ or C:/ using regex /^[a-zA-Z]:[/\\]/ - Windows UNC paths: \\server\share Removes unreliable temp/tmp path indicators and file: URL checks while maintaining fs fallback behavior for proper external file processing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 file changed
+5
-10
+5
-10
@@ -105,17 +105,12 @@ export class PathUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For paths that might be absolute but outside vault, use fs fallback
|
// For paths outside vault, use fs fallback (needed for external file processing)
|
||||||
// This handles external file processing (temp files, system paths, etc.)
|
const isAbsolutePath = path.startsWith('/') || // Unix absolute
|
||||||
// Check for common absolute path indicators across platforms
|
/^[a-zA-Z]:[/\\]/.test(path) || // Windows drive letter (C:\ or C:/)
|
||||||
const isLikelyAbsolutePath = path.startsWith('/') || // Unix absolute
|
path.startsWith('\\\\'); // Windows UNC path (\\server\share)
|
||||||
path.startsWith('\\') || // UNC paths
|
|
||||||
(path.length >= 3 && path[1] === ':') || // Windows drive letter (C:)
|
|
||||||
path.startsWith('file:') || // File URLs
|
|
||||||
path.includes('temp') || // Temp directory indicators
|
|
||||||
path.includes('tmp'); // Common temp paths
|
|
||||||
|
|
||||||
if (isLikelyAbsolutePath) {
|
if (isAbsolutePath) {
|
||||||
try {
|
try {
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
await fs.access(path);
|
await fs.access(path);
|
||||||
|
|||||||
Reference in new issue
Block a user