File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
main/java/org/springframework/web/util
test/java/org/springframework/web/util Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,7 @@ private static TemplateInfo parse(String uriTemplate) {
197197 if (c == '{' ) {
198198 level ++;
199199 if (level == 1 ) {
200+ // start of URI variable
200201 pattern .append (quote (builder ));
201202 builder = new StringBuilder ();
202203 continue ;
@@ -205,6 +206,7 @@ private static TemplateInfo parse(String uriTemplate) {
205206 else if (c == '}' ) {
206207 level --;
207208 if (level == 0 ) {
209+ // end of URI variable
208210 String variable = builder .toString ();
209211 int idx = variable .indexOf (':' );
210212 if (idx == -1 ) {
@@ -227,14 +229,11 @@ else if (c == '}') {
227229 continue ;
228230 }
229231 }
230- if (i + 1 == uriTemplate .length ()) {
231- if (c != '/' ) {
232- builder .append (c );
233- }
234- pattern .append (quote (builder ));
235- }
236232 builder .append (c );
237233 }
234+ if (builder .length () > 0 ) {
235+ pattern .append (quote (builder ));
236+ }
238237 return new TemplateInfo (variableNames , Pattern .compile (pattern .toString ()));
239238 }
240239
Original file line number Diff line number Diff line change @@ -185,6 +185,14 @@ public void fragments() throws Exception {
185185 assertTrue (template .matches ("/search?query=foo#bar" ));
186186 }
187187
188+ // SPR-13705
189+
190+ @ Test
191+ public void matchesWithSlashAtTheEnd () {
192+ UriTemplate uriTemplate = new UriTemplate ("/test/" );
193+ assertTrue (uriTemplate .matches ("/test/" ));
194+ }
195+
188196 @ Test
189197 public void expandWithDollar () {
190198 UriTemplate template = new UriTemplate ("/{a}" );
You can’t perform that action at this time.
0 commit comments