spring-hateoas icon indicating copy to clipboard operation
spring-hateoas copied to clipboard

Missing slash when generating link with context path

Open f-cramer opened this issue 2 years ago • 3 comments
trafficstars

When generating a link to a method which is mapped without a leading slash (@RequestMapping("hello")), the mapping generated in AnnotationMappingDiscoverer#getMapping(Class<?>, Method) does not have a leading slash as well.

If the request does not contain a context path this is not a problem, but if it does context path and mapping are concatenated without a slash inbetween.

imo this could be fixed by adding the leading slash in AnnotationMappingDiscoverer#cleanup(), but this would of course be a breaking change, which causes two tests in AnnotationMappingDiscovererUnitTest to fail

For an example see this repository and the test in com.example.HateoasSlashExampleApplicationTests

f-cramer avatar Feb 26 '23 23:02 f-cramer

Can I provide an more information to help fix this?

f-cramer avatar Apr 04 '23 17:04 f-cramer

An even more reduced example (Java, Maven) would certainly help.

odrotbohm avatar May 05 '23 07:05 odrotbohm

I updated the example to use Java and Maven

f-cramer avatar May 05 '23 11:05 f-cramer