File tree 2 files changed +16
-4
lines changed
main/java/org/springframework/web/util
test/java/org/springframework/web/util
2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -503,8 +503,7 @@ public void index(int index) {
503
503
// Component capture
504
504
505
505
public InternalParser resolveIfOpaque () {
506
- boolean hasSlash = (this .uri .indexOf ('/' , this .index + 1 ) == -1 );
507
- this .isOpaque = (hasSlash && !hierarchicalSchemes .contains (this .scheme ));
506
+ this .isOpaque = (this .uri .charAt (this .index ) != '/' && !hierarchicalSchemes .contains (this .scheme ));
508
507
return this ;
509
508
}
510
509
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -155,6 +155,19 @@ void fromOpaqueUri() {
155
155
assertThat (result .toUri ()).as ("Invalid result URI" ).isEqualTo (uri );
156
156
}
157
157
158
+ @ ParameterizedTest // see gh-34588
159
+ @ EnumSource
160
+ void fromOpaqueUriWithUrnScheme (ParserType parserType ) {
161
+ URI uri = UriComponentsBuilder
162
+ .fromUriString ("urn:text:service-{region}:{prefix}/{id}" , parserType ).build ()
163
+ .expand ("US" , "prefix1" , "Id-2" )
164
+ .toUri ();
165
+
166
+ assertThat (uri .getScheme ()).isEqualTo ("urn" );
167
+ assertThat (uri .isOpaque ()).isTrue ();
168
+ assertThat (uri .getSchemeSpecificPart ()).isEqualTo ("text:service-US:prefix1/Id-2" );
169
+ }
170
+
158
171
@ ParameterizedTest // see gh-9317
159
172
@ EnumSource
160
173
void fromUriEncodedQuery (ParserType parserType ) {
You can’t perform that action at this time.
0 commit comments