Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ensure protocol slashes are preserved in getSanitizedPath #33978

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sanhee
Copy link

@sanhee sanhee commented Nov 27, 2024

Description

When using WebClient with UriBuilder to construct URIs, I encountered a problem where a protocol's double slashes (://) were incorrectly reduced to a single slash (:/).
This behavior was traced back to the getSanitizedPath method, which removed redundant slashes without preserving the protocol structure.

Changes

  • Refined logic to ensure protocol slashes are preserved.
  • Cleaned up redundant slashes in the path without affecting the protocol.

Test

  • To validate and fix this behavior, I tested the private getSanitizedPath method using reflection.
    • Since the method is private and part of an internal class, reflection was necessary to access and evaluate its behavior in isolation.
  • Verified with multiple inputs, including paths with and without protocols, to ensure correct behavior.
AS-IS (Existing Issue) TO-BE (Fixed Behavior)
스크린샷 2024-11-27 오후 11 50 32 image

Example Test Case

Input: http://example.com//path/to//resource
Output: http://example.com/path/to/resource

Input: https://example.com//path
Output: https://example.com/path

Input: example.com//path
Output: example.com/path

Fixed an issue where `getSanitizedPath` incorrectly removed slashes in protocols like `http://`.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants