File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
main/java/org/springframework/web/util
test/java/org/springframework/web/util Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2024 the original author or authors.
2+ * Copyright 2002-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -503,8 +503,7 @@ public void index(int index) {
503503 // Component capture
504504
505505 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 ));
508507 return this ;
509508 }
510509
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2024 the original author or authors.
2+ * Copyright 2002-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -155,6 +155,19 @@ void fromOpaqueUri() {
155155 assertThat (result .toUri ()).as ("Invalid result URI" ).isEqualTo (uri );
156156 }
157157
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+
158171 @ ParameterizedTest // see gh-9317
159172 @ EnumSource
160173 void fromUriEncodedQuery (ParserType parserType ) {
You can’t perform that action at this time.
0 commit comments