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.
@@ -496,8 +496,7 @@ public void index(int index) {
496
496
// Component capture
497
497
498
498
public InternalParser resolveIfOpaque () {
499
- boolean hasSlash = (this .uri .indexOf ('/' , this .index + 1 ) == -1 );
500
- this .isOpaque = (hasSlash && !hierarchicalSchemes .contains (this .scheme ));
499
+ this .isOpaque = (this .uri .charAt (this .index ) != '/' && !hierarchicalSchemes .contains (this .scheme ));
501
500
return this ;
502
501
}
503
502
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