Skip to content

Introduce ability to NOT encode URIs with UriTemplate [SPR-16279] #20826

@spring-projects-issues

Description

@spring-projects-issues

Greg Turnquist opened SPR-16279 and commented

Spring HATEOAS leverage's Spring Framework's UriTemplate class. However, in certain scenarios, the user provides a URI Template that is already encoded (e.g. /foo/b%20ar{?x}). In this scenario, when creating a Spring Framework UriTemplate, the "%" gets encoded into%25. And because we wrap this some of our own goodness, it actually gets encoded twice when doing an expand (e.g. x=>1 in this case).

It would be useful if there was an optional to indicate "do not encode", possibly here?

public URI expand(Map<String, ?> uriVariables) {
     UriComponents expandedComponents = this.uriComponents.expand(uriVariables);
     UriComponents encodedComponents = expandedComponents.encode();
     return encodedComponents.toUri();
}

A flag here, or an overloaded method to side step encoding would make it possible.

Related issue


Reference URL: spring-projects/spring-hateoas#593

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions