spring-projects / spring-projects/spring-hateoas

Unable to expand() template link #169

Open
#543 2 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Mar 1, 2017.

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

Description

Given

ControllerLinkBuilderFactory linkBuilderFactory = new ControllerLinkBuilderFactory();
linkBuilderFactory.setUriComponentsContributors(singletonList(new HateoasPageableHandlerMethodArgumentResolver()));
@GetMapping("/deals")
    CollectionResource<DealResource> findDeals(
        @RequestParam(required = false) String title,
        @RequestParam(value = "category_id", required = false) Long categoryId,
        @RequestParam(value = "tags[]", required = false) String[] tags,
        @PageableDefault(sort = "position", direction = ASC) Pageable pageable)

When:

Link next = linkBuilderFactory.linkTo(methodOn(MobileVoucherDealsController.class)
                .findDeals(title, categoryId, tags, pageable.next())).withRel("next");

Then:
Link: http://localhost:8080/deals?page=1&size=1&sort=position,asc{&title,category_id,tags[]}

When:
From #535

Just expand the Link without handing any parameters into the method and you should get a plain URI in turn.

next.expand(TemplateVariables.NONE);

Then:

Illegal character in query at index 59: http://localhost:8080/deals?page=1&size=1&sort=position,asc{&title,category_id,tags[]}


I tried expanding links in the same manner like http://localhost:8080/deals{/id} and it works resulting in http://localhost:8080/deals but not with template being after URL request params

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.