-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Support fragments in UriComponentsBuilder.fromHttpUrl() #25300
Comments
I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference. |
Changing the RegEx pattern as follows would support fragments in the HTTP URL, but I'll hold off on implementing the change until I receive feedback from the team. private static final Pattern HTTP_URL_PATTERN = Pattern.compile(
"^" + HTTP_PATTERN + "(//(" + USERINFO_PATTERN + "@)?" + HOST_PATTERN + "(:" + PORT_PATTERN + ")?" + ")?" +
PATH_PATTERN + "(\\?" + QUERY_PATTERN + ")?" + "(#" + LAST_PATTERN + ")?"); |
@ljosefik what is the context in which you're using this? As you probably know a fragment is not sent with HTTP requests and is not available on the server side, so it is a client-side concept only, used in browsers. If you need to parse with the complete URI syntax including fragments, you can use |
Yes, method fromHttpUri can be used and we solved our problem with this approach. |
Yes fragment is definitely valid syntax. I wasn't making an argument the other way but simply guessing at this point as to the original intent which was quite a long time ago. I think we can change it to parse fragments if present. It should be lenient on parsing and also the |
Beginning with Spring Framework 5.2.8, |
Prior to this commit, UriComponentsBuilder.fromHttpUrl() threw an IllegalArgumentException if the provided URL contained a fragment. This commit aligns the implementation of fromHttpUrl() with that of fromUriString(), by parsing a fragment and storing it in the builder. Closes spring-projectsgh-25300
Method
fromHttpUrl
ends withIllegalArgumentException
if parameter contain fragmentTest case:
From code (for URL '#' missing):
The text was updated successfully, but these errors were encountered: