From 2e1d2673b1554d6d12e47e61af028be04cf848ad Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Tue, 4 Nov 2025 11:10:53 +0100 Subject: [PATCH] Simplifies path joining logic Simplifies the path joining logic by leveraging the built-in `path.join` method directly. This change removes the manual iteration and absolute path handling, resulting in more concise and readable code. Ensures correct path handling on Windows. --- src/core/PathUtils.ts | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/core/PathUtils.ts b/src/core/PathUtils.ts index ed45d80..254f8cc 100644 --- a/src/core/PathUtils.ts +++ b/src/core/PathUtils.ts @@ -32,33 +32,12 @@ export class PathUtils { * Handles absolute paths correctly by using the last absolute path found */ joinPath(...segments: string[]): string { - // Filter out empty segments const filtered = segments.filter(s => s); - if (filtered.length === 0) { return ''; } - - // Find the last absolute path in the segments - // If a segment is absolute, it becomes the new base and we ignore previous segments - let result = ''; - for (const segment of filtered) { - if (path.isAbsolute(segment)) { - // This segment is absolute, use it as the new base - result = segment; - } else if (result) { - // Join with the current result - result = path.join(result, segment); - } else { - // First relative segment - result = segment; - } - } - - // Normalize the final path using path.normalize for cross-platform compatibility - // then use Obsidian's normalizePath for vault-relative paths - const normalized = path.normalize(result); - return normalizePath(normalized); + const result = path.join(...filtered); + return normalizePath(result); } /**