Skip to content

AnnotationMappingDiscoverer does not preserve trailing mapping slashes #1468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nealeu opened this issue Feb 16, 2021 · 0 comments
Closed

AnnotationMappingDiscoverer does not preserve trailing mapping slashes #1468

nealeu opened this issue Feb 16, 2021 · 0 comments
Assignees
Labels
in: core Core parts of the project type: bug
Milestone

Comments

@nealeu
Copy link

nealeu commented Feb 16, 2021

In #269 the following problem is raised and never resolved:

Using linkTo(methodOn()) to reference an endpoint with a trailing slash removes the trailing slash.

@RequestMapping("/api/myentities/")

result: http://localhost:6010/api/myentities

This is an obvious situation where there is either a bug (the trailing slash should not be removed), or there is something opinionated going on (e.g. HATEOAS links should never end in /).

If not a bug, then a developers code is always going to break and then have messy workarounds, therefore Spring HATEOAS should be clear.

I suggest that if this is the case, then it would make most sense to throw IllegalArgumentException with an appropriate comment that the trailing slash should be removed (this is safe because the endpoint will still be resolved correctly if a trailing slash is added to a request - but not the reverse)

@odrotbohm odrotbohm self-assigned this Feb 16, 2021
@odrotbohm odrotbohm added this to the 1.3 M2 milestone Feb 16, 2021
@odrotbohm odrotbohm added in: core Core parts of the project type: bug labels Feb 16, 2021
@odrotbohm odrotbohm changed the title Endpoint with trailing slash should be preserved or else throw IllegalArgumentException in linkTo(methodOn(..)) AnnotationMappingDiscoverer does not preserve trailing mapping slashes Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Core parts of the project type: bug
Projects
None yet
Development

No branches or pull requests

2 participants