Skip to content

Make StandardizedPath::strip_prefix component-aware#11936

Open
tkshsbcue wants to merge 1 commit into
warpdotdev:masterfrom
tkshsbcue:fix/standardized-path-strip-prefix-component-aware
Open

Make StandardizedPath::strip_prefix component-aware#11936
tkshsbcue wants to merge 1 commit into
warpdotdev:masterfrom
tkshsbcue:fix/standardized-path-strip-prefix-component-aware

Conversation

@tkshsbcue
Copy link
Copy Markdown

@tkshsbcue tkshsbcue commented May 30, 2026

StandardizedPath::strip_prefixstripped a raw string prefix instead of matching whole path components. As a result a base like/repowas treated as a prefix of the sibling path/repository/foo.rs, returning a bogus mid-component remainder Some("sitory/foo.rs")instead ofNone`.

This contradicted the sibling starts_with/ends_with methods (both component-aware) and silently broke LocalOrRemotePath::strip_repo_prefix for remote paths: its Local arm uses the component-aware Path::strip_prefix and correctly rejects siblings, while its Remote arm went through this method and mis-attributed files in a sibling directory to the repo.

Gate the strip on the component-aware starts_with before slicing. For two normalized paths a component prefix is also a byte prefix, so the cut lands on a component boundary. Add regression tests at both the StandardizedPath and strip_repo_prefix levels.

solve #11937

`StandardizedPath::strip_prefix` stripped a raw string prefix instead of
matching whole path components. As a result a base like `/repo` was
treated as a prefix of the sibling path `/repository/foo.rs`, returning a
bogus mid-component remainder `Some("sitory/foo.rs")` instead of `None`.

This contradicted the sibling `starts_with`/`ends_with` methods (both
component-aware) and silently broke `LocalOrRemotePath::strip_repo_prefix`
for remote paths: its `Local` arm uses the component-aware
`Path::strip_prefix` and correctly rejects siblings, while its `Remote`
arm went through this method and mis-attributed files in a sibling
directory to the repo.

Gate the strip on the component-aware `starts_with` before slicing. For
two normalized paths a component prefix is also a byte prefix, so the cut
lands on a component boundary. Add regression tests at both the
`StandardizedPath` and `strip_repo_prefix` levels.
@cla-bot cla-bot Bot added the cla-signed label May 30, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 30, 2026

@tkshsbcue

This PR is not linked to an issue that is marked with ready-to-implement.

Issue-state enforcement details:

  • Associated same-repo issues checked: none

  • Required readiness label: ready-to-implement

To continue, link this PR to a same-repo issue such as Closes #123 in the PR description, and make sure that issue has ready-to-implement.

Powered by Oz

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label May 30, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkshsbcue

This PR is not linked to an issue that is marked with ready-to-implement.

Issue-state enforcement details:

  • Associated same-repo issues checked: none

  • Required readiness label: ready-to-implement

To continue, link this PR to a same-repo issue such as Closes #123 in the PR description, and make sure that issue has ready-to-implement.

Powered by Oz

@tkshsbcue
Copy link
Copy Markdown
Author

/oz-review

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkshsbcue

This PR is not linked to an issue that is marked with ready-to-implement.

Issue-state enforcement details:

  • Associated same-repo issues checked: none

  • Required readiness label: ready-to-implement

To continue, link this PR to a same-repo issue such as Closes #123 in the PR description, and make sure that issue has ready-to-implement.

Powered by Oz

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

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant