Summary#
- keep the final path segment when a directory is written with a trailing
/ or \
- chips for paths like
/tmp/favicons/ rendered with no label at all
Closes #5291
Why#
basenameOfPath in markdown-links.ts took 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:
- POSIX directory path with a trailing slash keeps its final segment
- Windows directory path with a trailing backslash keeps its final segment
- a path with and without a trailing separator produce the same label
- a directory path does not produce an empty label
vp test run apps/web/src/markdown-links.test.ts — 37 passed
vp lint — clean
Bare / and // still return an empty segment, but they never reach this function: resolveMarkdownFileLinkTarget rejects them because a root prefix such as /tmp/ or /Users/ is required. Verified with a throwaway test.
Notes#
filePathDisplay.ts and pierre-icons.ts each 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 basenameOfPath to return the final segment of directory paths with a trailing separator#
basenameOfPath in 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 cdbd70f.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
9fc0e757-7ac7-4cdf-b59f-d6222d9379ddYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share