Skip to content

Commit ba5f4f5

Browse files
committed
Merge branch '5.2.x'
2 parents 115ea25 + 9876ca0 commit ba5f4f5

File tree

2 files changed

+178
-87
lines changed

2 files changed

+178
-87
lines changed

spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
* @author Oliver Gierke
6161
* @author Brian Clozel
6262
* @author Sebastien Deleuze
63+
* @author Sam Brannen
6364
* @since 3.1
6465
* @see #newInstance()
6566
* @see #fromPath(String)
@@ -96,7 +97,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
9697

9798
private static final Pattern HTTP_URL_PATTERN = Pattern.compile(
9899
"^" + HTTP_PATTERN + "(//(" + USERINFO_PATTERN + "@)?" + HOST_PATTERN + "(:" + PORT_PATTERN + ")?" + ")?" +
99-
PATH_PATTERN + "(\\?" + LAST_PATTERN + ")?");
100+
PATH_PATTERN + "(\\?" + QUERY_PATTERN + ")?" + "(#" + LAST_PATTERN + ")?");
100101

101102
private static final String FORWARDED_VALUE = "\"?([^;,\"]+)\"?";
102103

@@ -293,6 +294,10 @@ public static UriComponentsBuilder fromHttpUrl(String httpUrl) {
293294
}
294295
builder.path(matcher.group(8));
295296
builder.query(matcher.group(10));
297+
String fragment = matcher.group(12);
298+
if (StringUtils.hasText(fragment)) {
299+
builder.fragment(fragment);
300+
}
296301
return builder;
297302
}
298303
else {

0 commit comments

Comments
 (0)