Skip to content

fix: check POSIX absolute path before Win32 in resolveSymlinks#75

Open
laplaque wants to merge 1 commit intojacksteamdev:mainfrom
laplaque:fix/resolve-symlinks-posix-path
Open

fix: check POSIX absolute path before Win32 in resolveSymlinks#75
laplaque wants to merge 1 commit intojacksteamdev:mainfrom
laplaque:fix/resolve-symlinks-posix-path

Conversation

@laplaque
Copy link
Copy Markdown

@laplaque laplaque commented Apr 2, 2026

Summary

Fixes #36 — duplicate /home/<user> in server install path on Linux/macOS/WSL.

Root cause: path.win32.isAbsolute() returns true for POSIX absolute paths (a leading / is treated as the current drive root in Win32). Since it was checked first in the if/else-if chain, path.posix.isAbsolute() was never reached on non-Windows platforms. This caused the root segment to be set to "" instead of "/", producing a relative path. realpath then resolved it against CWD, prepending the home directory on every path component — and compounding with each settings panel open or install attempt.

Fix: Swap the if/else-if order so path.posix.isAbsolute() is checked first. This is a one-line logic change (plus explanatory comments) with no behavioral impact on Windows, where path.posix.isAbsolute() returns false for drive-letter paths like C:\....

Note on existing PRs

PRs #45 and #52 address the same issue with a post-hoc removeDuplicatePathSegments() function. This PR instead fixes the root cause directly, avoiding the need for path deduplication heuristics.

Test plan

  • Verify server install works on Linux/WSL with a vault path like /home/user/vault
  • Verify server install still works on Windows with drive-letter paths
  • Verify server install still works on macOS
  • Verify symlinked vault paths still resolve correctly

path.win32.isAbsolute() returns true for POSIX absolute paths
(a leading "/" is treated as the current drive root), so checking
it first causes the root segment to be set to "" instead of "/".
This produces a relative path, and realpath then resolves it
against CWD — prepending the home directory on every iteration.

Swapping the if/else-if order so path.posix.isAbsolute() is
checked first fixes the duplicate path issue on Linux/macOS/WSL.

Fixes jacksteamdev#36
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for superb-starlight-b5acb5 canceled.

Name Link
🔨 Latest commit 3e084a6
🔍 Latest deploy log https://app.netlify.com/projects/superb-starlight-b5acb5/deploys/69ce59d491ada70008e2a1a5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Download Path contains duplicate /home/<user>

2 participants