Skip to content

Links are relative to request context #527

@cheinema

Description

@cheinema

Since 0.22.0.RELEASE, links are built relative to the request context. The following test case in ControllerLinkBuildUnitTest runs with success against the previous release, but fails with the current.

@Test
public void createsLinkRelativeToContextRoot() {

    request.setContextPath("/ctx");
    request.setServletPath("/foo");
    request.setRequestURI("/ctx/foo");

    assertThat(linkTo(PersonControllerImpl.class).withSelfRel().getHref(), endsWith("/ctx/people"));
}
java.lang.AssertionError: 
Expected: a string ending with "/ctx/people"
     but: was "http://localhost/ctx/foo/people"
Expected :a string ending with "/ctx/people"

This would be a regression to our application due to the invalid links.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions