spring-projects / spring-projects/spring-data-rest

Malformed URL causes issues with self links [DATAREST-371]

Open
#752 0 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

in: repository type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Andrew Hill opened DATAREST-371 and commented

If the URL for a search contains an additional slash the self links on the items that are returned are malformed.

e.g.
a normal search url;
http://127.0.0.1:8080/pepperAPI/item/search/findByName?name=angular-ui-bootstrap

The response self reference (on the embedded items) is;
http://127.0.0.1:8080/pepperAPI/item/3

However when the url is (notice the extra slash between items and search);
http://127.0.0.1:8080/pepperAPI/item//search/findByName?name=angular-ui-bootstrap

Then the (incorrect) response self reference (on the embedded items) is;
http://127.0.0.1:8080/pepperAPI/item/search/findByName/item/3

The same thing happens if you put the double slash anywhere after the API root (in this case pepperAPI it the webapp root).

Ideally we would get either a 404 not found or it would construct the correct self URL.

Update:

This also occurs with collection roots (notice the extra slash between pepperAPI and item);
http://127.0.0.1:8080/pepperAPI//item

The (incorrect) response self reference (on the embedded items) is;
http://127.0.0.1:8080/pepperAPI/item/item/3

This may be the same issue or a separate one. When given the following URL(notice the extra trailing slash);
http://127.0.0.1:8080/pepperAPI/items//

The response given is the same as the API root (http://127.0.0.1:8080/pepperAPI) - i.e. a list of collection roots.


Affects: 2.1.2 (Dijkstra SR2)

Contributor guide

Open the contributing guide

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.