Skip to content

fix(directory): ignore trailing separators on home and project dirs - #134

Merged
FallDownTheSystem merged 1 commit into
mainfrom
fix/home-trailing-separator
Oct 10, 2026
Merged

FallDownTheSystem merged 1 commit into
mainfrom
fix/home-trailing-separator

Conversation

@FallDownTheSystem

Copy link
Copy Markdown
Collaborator

Follow-up to #131.

With HOME=/home/al/, paths under it were no longer collapsed to ~. A project dir with a trailing separator (/srv/app/) had the same problem, so its subfolders showed as full paths instead of relative ones.

Both callers matched the base path and then sliced by its length, which assumes the base has no trailing separator. pathBelow replaces isPathWithin. It trims the base's trailing separators and returns the remainder itself, so callers no longer slice by length. A root base such as / keeps its separator and only matches itself, so HOME=/ still leaves paths unchanged.

Tests cover both the helper and the directory segment. The two new segment tests fail on main.

A HOME of /home/al/ stopped collapsing paths under it to ~, and a project
dir of /srv/app/ stopped showing subfolders relative to it. Both callers
matched the base path and then sliced by its length, which assumes the
base never ends in a separator.

pathBelow replaces isPathWithin and returns the remainder below the base
itself, so callers no longer slice by length. A root base such as / still
only matches itself.
@FallDownTheSystem
FallDownTheSystem merged commit 18e843f into main Oct 10, 2026
2 checks passed
@pgagnidze

Copy link
Copy Markdown
Member

🎉 This PR is included in version 1.32.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants