Skip to content

fix: strip nested BasePathFs prefixes in file names#617

Open
leno23 wants to merge 1 commit into
spf13:masterfrom
leno23:fix/basepathfs-nested-name-trim
Open

fix: strip nested BasePathFs prefixes in file names#617
leno23 wants to merge 1 commit into
spf13:masterfrom
leno23:fix/basepathfs-nested-name-trim

Conversation

@leno23

@leno23 leno23 commented May 25, 2026

Copy link
Copy Markdown

Summary

  • Fixes BasePathFile.Name() returning paths that still contain parent base prefixes when BasePathFs instances are nested
  • Replace naive strings.TrimPrefix(filepath.Clean(base)) with relative-name computation that handles mixed absolute/relative base paths and separator prefixes

Test plan

  • Added TestNestedBasePathTempFileName reproducing nested TempFile + Chmod failure
  • Existing TestBasePath* and nested copy tests still pass
  • go test ./...

Fixes #428

BasePathFile.Name() used strings.TrimPrefix on filepath.Clean(base),
which failed for nested BasePathFs when the stored path and inner
file name used inconsistent separators or leading slashes. Compute
the name relative to the base path instead.

Fixes spf13#428
@CLAassistant

CLAassistant commented May 25, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@leno23 leno23 force-pushed the fix/basepathfs-nested-name-trim branch from f14904a to 382557e Compare May 26, 2026 04:41
@spf13

spf13 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Thanks for these contributions. Before we can review and merge, you'll need to sign the Contributor License Agreement (CLA). Please do so and then let us know — we'll pick up the review from there.

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.

BasePathFs wrongly trims path prefix.

3 participants