Skip to content

fix: resolve path-style wikilinks on Windows backslash paths (#885)#886

Open
thfaix wants to merge 2 commits into
refactoringhq:mainfrom
thfaix:fix/windows-path-suffix-wikilink
Open

fix: resolve path-style wikilinks on Windows backslash paths (#885)#886
thfaix wants to merge 2 commits into
refactoringhq:mainfrom
thfaix:fix/windows-path-suffix-wikilink

Conversation

@thfaix

@thfaix thfaix commented Jun 12, 2026

Copy link
Copy Markdown

Summary

Path-style wikilinks ([[folder/note]]) silently fail to resolve on Windows — clicking the link does nothing.

resolveEntry's Pass-1 findEntryByPathSuffix (src/utils/wikilink.ts) compared entry.path against path suffixes built with forward slashes (/folder/note.md):

entry.path.toLowerCase().endsWith(pathSuffix)

But entry.path carries OS-native separators — on Windows it's produced by path.to_string_lossy() in src-tauri/src/vault/mod.rs, so it uses backslashes (folder\note.md). A backslash path never .endsWith() a forward-slash suffix, so the path-suffix pass never matched on Windows. Links then either fell through to the filename-stem pass (resolving to the wrong note when two notes share a filename across folders) or failed entirely, leaving the click dead.

This is the ADR-0035 "Obsidian-style, zero-config path-suffix resolution" feature breaking on Windows.

Fix

Normalize entry.path with the existing normalizeFilesystemPath helper (already used by relativePathStem) before the endsWith comparison — a one-helper change that brings path-suffix matching in line with the rest of the module.

Tests

Added two regression tests in src/utils/wikilink.test.ts covering Windows backslash entry paths, including the subfolder-disambiguation case the filename-stem fallback could not mask. Followed the repo's TDD process (red → green).

Verified locally:

  • pnpm exec vitest run4461 passed (407 files)
  • npx tsc --noEmit — clean
  • npx eslint src/utils/wikilink.ts src/utils/wikilink.test.ts — clean

I could not run the native pre-push lane locally (Playwright smoke / cargo / CodeScene PAT-gated steps); leaving those to CI.

Repro

  1. Open a vault with subfolders on Windows 11 (Tolaria 2026.6.10).
  2. Add [[folder/note]] linking to a note in a subfolder.
  3. Click it → before this fix, nothing happens (DevTools shows Navigation target not found: folder/note); after, the target note opens.

Fixes #885

Thiébaud Faix and others added 2 commits June 12, 2026 11:26
findEntryByPathSuffix compared entry.path against forward-slash path
suffixes, but entry.path carries OS-native separators (backslashes on
Windows, via path.to_string_lossy in src-tauri). A backslash path never
ends with a forward-slash suffix, so Pass-1 path-suffix resolution
silently failed on Windows: [[folder/note]] links resolved to the wrong
note (or not at all when no filename-stem fallback matched), and the
click did nothing.

Normalize entry.path with the existing normalizeFilesystemPath helper
(already used by relativePathStem) before the endsWith comparison.

Adds regression tests for Windows backslash entry paths, including the
subfolder-disambiguation case that the filename-stem fallback could not
mask.

Fixes refactoringhq#885
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.

Path-style wikilinks ([[folder/note]]) don't resolve on Windows — click does nothing

1 participant