fix: resolve . and .. components in middle of file paths (#108)#215
Open
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
Open
fix: resolve . and .. components in middle of file paths (#108)#215Koan-Bot wants to merge 1 commit intocpanel:masterfrom
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
Conversation
Replace regex-based path normalization loop with component-based resolution. The old approach only handled /. at end of path and could produce empty strings for paths like /there/.. — the new split/resolve approach handles all positions correctly: - /there/./xyz now resolves to /there/xyz (was unchanged before) - /there/.. resolves to / (was empty string before) - /../foo resolves to /foo (was unhandled) - / preserves as / (was stripped to empty by trailing slash regex) Also moves tilde expansion before absolutification for clarity and removes the special-case return for /.. (now handled naturally). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8b9079a to
6bb28ab
Compare
atoomic
approved these changes
Feb 25, 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.
Summary
_abs_path_to_filefrom regex-based loop to component-based path resolution/there/./xyz(was not resolved — caused strict mode violations per Convert relative paths on opendir/open #108)/there/..producing empty string instead of//../foonot being handled (only/..had a special case)/being stripped to empty string by the trailing slash regexWhat changed
The old approach used iterative regex substitutions that only handled
/.at end of path and had edge cases where..resolution could produce empty strings. The new approach splits the path into components, filters.and resolves.., then rejoins — handling all positions naturally.Test plan
_abs_path_to_fileedge cases (.mid-path,..at root, multiple slashes, root preservation)stat/-d/-e/-fon mocked files accessed through/./and/../paths🤖 Generated with Claude Code