Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): keep the final segment of directory paths with a trailing separator #5460

Mergedjorvarea(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/5460/headmerged by juliusmarminge View on GitHub

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.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 9fc0e757-7ac7-4cdf-b59f-d6222d9379dd

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Approvability

      Verdict: 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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge merged thisf915320

    5. juliusmarminge closed this

Sign in to join this conversation.