fix: Normalize paths to prevent double slashes causing 404 errors (#37)#53
Open
vanmarkic wants to merge 2 commits intojacksteamdev:mainfrom
Open
Conversation
…cksteamdev#37) When querying the list_vault_files endpoint with a directory parameter containing a trailing slash (e.g., "DevOps/"), the system would generate paths with double slashes (e.g., "/vault/DevOps//"), resulting in HTTP 404 errors. This fix adds path normalization that strips trailing slashes before constructing the API path, ensuring consistent behavior regardless of whether users include trailing slashes in directory parameters. Fixes jacksteamdev#37
- Test removal of single and multiple trailing slashes - Test handling of paths without trailing slashes - Test empty and undefined directory inputs - Test nested paths with various trailing slash scenarios - Test API path construction prevents double slashes - Verify the fix for /vault//Documents/ bug
✅ Deploy Preview for superb-starlight-b5acb5 canceled.
|
istefox
added a commit
to istefox/obsidian-mcp-tools
that referenced
this pull request
Apr 11, 2026
…cluster E) Fix four related path-resolution bugs that combined to make the Linux and WSL installation paths unusable and list_vault_files crash-prone on some layouts: 1. POSIX-vs-Win32 absoluteness check order (PR jacksteamdev#75, laplaque) `path.win32.isAbsolute("/foo")` returns true because in Win32 semantics a leading "/" is the root of the current drive. The previous code checked Win32 first, so on Linux / macOS / WSL it would push `parts[0]` (an empty string) instead of "/", producing a relative-looking path that made realpath prepend CWD repeatedly. Now checks POSIX first. 2. Duplicate path segments after symlink resolution (PR jacksteamdev#52, vanmarkic) On some iCloud Drive / symlinked vault layouts, `fsp.realpath` returns paths like `/home/user/home/user/vault` or `/Users/me/Library/Mobile Documents/Users/me/Library/Mobile Documents/vault`. These doubled paths broke the subsequent filesystem checks in getInstallationStatus. Added a new `removeDuplicatePathSegments()` helper in a dedicated module (`services/pathSegments.ts`) that walks the segment list and collapses any run matching the tail of what it has already accumulated. resolveSymlinks calls it after every successful realpath. Isolated in its own module so the pure logic is unit-testable without pulling in Obsidian imports. 3. Linux Claude Desktop config path (PR jacksteamdev#49, vanmarkic, issue jacksteamdev#31) Constants said `~/.config/claude/config.json`. Actual Claude Desktop Linux install uses `~/.config/Claude/claude_desktop_config.json` (capital C, full filename, matching macOS/Windows). Fixed. Also split the static path constants into a macro-free module (`constants/paths.ts`) so they can be imported from unit tests without triggering the `environmentVariables()` bundle-time macro. 4. Double slashes at vault root (PR jacksteamdev#53, vanmarkic) `list_vault_files` concatenated `args.directory` directly, so callers passing `"Documents/"` produced `/vault/Documents//` which Local REST API returns as HTTP 500. Now strips trailing slashes before composing the URL. Adds three new test files: - services/status.test.ts: 8 tests for removeDuplicatePathSegments (simple duplicate, multiple runs, multi-segment prefix, no-dup preservation, single-segment, similar-but-distinct, bare root, real-world iCloud case). - constants/constants.test.ts: 12 tests for the platform constants (including explicit regression on the Linux capital-C fix). - features/local-rest-api/pathNormalization.test.ts: 13 tests for the trailing-slash stripping logic in list_vault_files (single slash, multiple slashes, undefined, nested paths, vault-boundary double-slash prevention). Total: 33 new tests across server + plugin packages. Plugin went from 0 tests to 20. Refs: jacksteamdev#31, jacksteamdev#36, jacksteamdev#37 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
Related Issue
Fixes bug #37
🤖 Generated with Claude Code