Repository navigation
[patch] Keep ".." segments that climb above the start in RelativeDirectoryPath.Normalize - #380
Merged
Merged
Conversation
…ctoryPath.Normalize Normalize resolved the path against a dummy filesystem root, where a ".." at the root resolves to the root itself, so "../sibling" became "sibling" and the path named a different directory. Resolve the segments lexically instead: "." is dropped, ".." pops the previous segment when there is one that is not itself "..", and is kept otherwise. Fixes #288 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MZE6sRR8wRTGhthCM8sL2M
|
This was referenced Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #288
What changed
RelativeDirectoryPath.Normalize()used to resolve the path against a dummy root (/orC:\) withPath.GetFullPath, then make it relative again. At the root,..resolves to the root itself, so every..that climbed above the starting point was dropped. For example,../siblingbecamesibling, which names a different directory.The segments are now resolved lexically:
.is dropped...removes the previous segment when there is one that isn't itself... Otherwise it is kept.., which is what the old code returned.Because no dummy root is involved, the result is the same on every OS. The
System.Runtime.InteropServicesimport is gone, since it was only used to pick that root.../siblingsibling../siblinga/../../bb../b../../x/yx/y../../x/ya/./b/../ca/ca/cTests
Normalize_WithOnlyDots_ResolvesCorrectlynow checks for exactly../folder. Before, it only checked that the result containedfolder.Normalize_KeepsParentSegmentsThatClimbAboveTheStart, covers the issue's table plusa/./b/../canda/...PathUtilityTestspass, and the wholePathsslice passes (186 passed, 2 skipped).Semantics.Pathsbuilds cleanly for every target (net8–10, netstandard2.0/2.1), and the local Sonar analyzer build (.sonarlint/sonar-local.props) is clean too.🤖 Generated with Claude Code
https://claude.ai/code/session_01MZE6sRR8wRTGhthCM8sL2M
Generated by Claude Code