os: handle empty path segments in join_path
#19877
Merged
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.
Not handling empty path segments might result in an unexpected path. E.g. when there is a base variable that might be empty, a path would become a root path unintentionally.
Currently, it is:
With the changes it becomes
'abc'
. This would be the same way go is joining paths. Where:🤖 Generated by Copilot at a00c73b
This pull request improves the
os.join_path
function and its tests. It fixes a bug that caused incorrect paths when joining empty strings or strings with separators, and adds more test cases for different operating systems and scenarios.🤖 Generated by Copilot at a00c73b
os.join_path
that would produce incorrect paths with empty strings or leading separators (link)os.join_path
inos_test.v
, covering empty and separator scenarios and using conditional compilation for different OSes (link)