Spring-hateoas: ControllerLinkBuilder.linkTo dont encode slash in parameters

Created on 27 Mar 2017  路  4Comments  路  Source: spring-projects/spring-hateoas

I have a code like this

ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(MyClass.class)
                               .MyMethod(param1, param2, param3));

when my param3 is equal to "aa/bb" i want to have na encoded url who will contain "aa%2Fbb" but the slash is not encoded and i get a value containing "aa/bb"

and when i try to encode it and give the methode and encoded parameter like this

String encodedParam3= java.net.URLEncoder.encode(param3, "UTF-8");
ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(MyClass.class)
                               .MyMethod(param1, param2, encodedParam3));

ControllerLinkBuilder.linkTo will encode the "%" in my encodedParam3 to "%25" and i will get a value containing "aa%252Fbb"

I am using spring hateoas 0.23.0-RELEASE

Most helpful comment

Any update on this issue? I am having the same issue with spring hateoas 1.1.2-RELEASE using WebMvcLinkBuilder.

All 4 comments

UP

I'm running the exact same issues with spring-hateoas 0.23.0-RELEASE

Related to #593. Looks like we won't be able to address this until Affordances API is merged given the pending updates to UriTemplate.

You can possibly work around this by encoding yourself and decoding on the server.

Any update on this issue? I am having the same issue with spring hateoas 1.1.2-RELEASE using WebMvcLinkBuilder.

Was this page helpful?
0 / 5 - 0 ratings