fix(web): keep the final segment of directory paths with a trailing separator - #5460
fix(web): keep the final segment of directory paths with a trailing separator#5460jorvarea wants to merge 3 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved a8908e0 Straightforward bug fix for a display issue where directory paths with trailing separators rendered with empty labels. The change is a simple string trim with fallback, isolated to a single utility function, and well-covered by new unit tests. You can customize Macroscope's approvability policy. Learn more. |
Summary
/or\/tmp/favicons/rendered with no label at allCloses #5291
Why
basenameOfPathinmarkdown-links.tstook everything after the last separator. A trailing separator is a valid way to write a directory, so the final segment came back as the empty string and the chip rendered as a bare folder icon with no text. The same path without the trailing separator rendered correctly.Change
Trim trailing separators before taking the final segment. Four lines in one function.
Tests
Four cases added to
markdown-links.test.ts, all failing before the change:vp test run apps/web/src/markdown-links.test.ts— 37 passedvp lint— cleanBare
/and//still return an empty segment, but they never reach this function:resolveMarkdownFileLinkTargetrejects them because a root prefix such as/tmp/or/Users/is required. Verified with a throwaway test.Notes
filePathDisplay.tsandpierre-icons.tseach carry their own copy of this helper with the same behaviour. They are not on the path this issue describes, so this change leaves them alone rather than growing into a refactor. Consolidating the three is worth a separate change.Verified via unit tests rather than in the running app.
🤖 Generated with Claude Code
Note
Fix
basenameOfPathto return the final segment of directory paths with a trailing separatorbasenameOfPathin markdown-links.ts previously returned an empty string for paths ending with/or\. It now trims trailing separators before extracting the last segment, falling back to the original path if trimming produces an empty string.Macroscope summarized 3af0e7a.