Fixes spring-cloud/spring-cloud-gateway#3201

Comment From: pivotal-cla

@bsgrd Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-cla

@bsgrd Thank you for signing the Contributor License Agreement!

Comment From: jhoeller

@bsgrd has this been tried with Spring Cloud Gateway already? If this change is definitely sufficient for the purposes there, that would be great to know. Also, do you happen to have any unit tests for the empty template case, e.g. for UriTemplateTests?

Last but not least, it would be great to rebase this PR onto our 6.1.x branch since that is were it would get merged first.

Comment From: jhoeller

Just added a few unit tests to UriTemplateTests locally, seems to work fine so far. No need to go to extra lengths on your side if you don't have any existing unit tests, I'd be happy to add mine then.

It would be great to know whether this works with Spring Cloud Gateway, in any case. And it would help to have the PR rebased onto 6.1.x, we could merge it as-is for tomorrow's 6.1.5 release then.

Comment From: bsgrd

@jhoeller Thank you for your feedback. I have added the unittest I made when making the changes. If you have tests that are more comprehensive, feel free to push 😊 Regarding the rebase, can I just change the target branch in the PR to 6.1.x?

Comment From: jhoeller

@bsgrd thanks that helps. As for the rebase, no worries, we'll handle that on our side.

Comment From: snicoll

@bsgrd thanks very much for making your first contribution to Spring Framework.