Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Updated the fix for normalize the URL #49

Merged
merged 6 commits into from
Apr 18, 2018

Conversation

jayasheelankumar
Copy link
Member

Updated the fix for normalize the URL

@jayasheelankumar jayasheelankumar self-assigned this Apr 13, 2018
// Remove leading '/' chars
while ((path.length() > 0) && (path.charAt(0) == '/')) {
path = path.substring(1);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is expected that leading '/' characters are stripped during this method. You could move the stripping of leading '/''s to the end of this method instead of doing it 1st. And you could add a leading '/' at the beginning to ensure it always has one... that might work. I suspect w/ this latest the path ../bad/path would fail to throw an exception.

Also, I recommend that you check in these test cases (I can submit a PR if you'd like). This way it will ensure these cases always get considered when making changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I opened a PR to your PR which adds a few tests.

@jayasheelankumar
Copy link
Member Author

@kenpaulsen Thanks for your comments. I have updated the fix considering all the cases.

// which is fine, unless it is also at the beginning...
if (path.equals("..")) {
path = null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could do an else if (path.endsWith("/") to avoid the need to check for null. But looks good either way!

@kenpaulsen
Copy link
Contributor

Minor (optional) comment. Looks good!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants