Micronaut's UriMatchTemplate.match method doesn't work the same as how Spring's UriTemplate #4582
-
I'm migrating my application from Spring Boot to Micronaut and found out that UriMatchTemplate is not exactly the same. Probably it's a bug, I am not sure yet, to figure it out I created this issue. The main difference is that I have this URL format: private static final String URL_FORMAT = "https://www.mydomain.com/post/{postSlug}"; Spring Boot original code: UriTemplate template = new UriTemplate(MOVIE_URL_FORMAT);
Map<String, String> match = template.match("https://www.mydomain.com/post/abc");
// will return `abc`
match.get("postSlug"); I have converted this code to Micronaut: UriMatchTemplate template = UriMatchTemplate.of(URL_FORMAT);
// will return `Optional.empty`
Optional<UriMatchInfo> match = template.match("https://www.mydomain.com/post/abc") I expect it will return Example ApplicationPlease clone this repo: https://github.com/donbeave/micronaut-uritemplate, here is two tests which compare Micronaut and Spring behavior: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
It is not a design goal for
To achieve the same behaviour in Micronaut |
Beta Was this translation helpful? Give feedback.
-
Apologies the + is actually before the path. See for examples If anything IMO Micronaut implements the spec more accurately. See “Reserved Expansion” section https://tools.ietf.org/html/rfc6570#section-3.2.3 |
Beta Was this translation helpful? Give feedback.
It is not a design goal for
UriMatchTemplate
to be the same as the Spring impl. I believe you can use:To achieve the same behaviour in Micronaut