fix(reflection): ensure complete stripping of relative paths with multiple leading slashes #4844
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.
This PR addresses an issue where relative paths with leading slashes and dots were not being stripped correctly. The problem arises when the 'path' contains multiple leading slashes like
../../
, as the current logic strips it to/../
, which is incorrect and prevents the entity from being discovered.This code modification ensures that any dots followed by slashes are stripped to provide the full path without any dots and slashes at the beginning.
Please note: that the current behavior is such that if you pass
./my/path
the result is/my/path
However, with the updated code, the result will bemy/path
This change is made because, in the end, we use the resulting path to check if thesource
contains the path usingendsWith
, and the leading slash is unnecessary for this purpose.Update
I added a slash again after @B4nan clarified a case that we need it in this thread
so the result now for
./my/path
will be/my/path