spring-projects / spring-projects/spring-hateoas

Missing slash when generating link with context path

Open
#1,922 3 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since May 5, 2023.

process: waiting for feedback
Dominant language
Java
Stars
1.1k
Forks
476
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.