damnhandy / Handy-URI-Templates

A Java URI Template processor implementing RFC6570

Home Page:https://damnhandy.github.io/Handy-URI-Templates/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot expand a template which contains colon in one of its query param

sandeep14-singh opened this issue · comments

Lets say, we have a template = https://someUrl{?someQuery:Param} where the we have a query param which has colon in it = "someQuery:Param"
If i try to expand this via :

Map<String, Object> templateParams = new HashMap<>();
templateParams.put("someQuery:Param", "hello");
UriTemplate
          .fromTemplate("https://someUrl{?someQuery:Param}").expand(templateParams);

It fails with -
com.damnhandy.uri.template.MalformedUriTemplateException: The prefix value for repo was not a number

at com.damnhandy.uri.template.Expression.parseRawExpression(Expression.java:329)
at com.damnhandy.uri.template.Expression.<init>(Expression.java:268)
at com.damnhandy.uri.template.impl.UriTemplateParser.endExpression(UriTemplateParser.java:225)
at com.damnhandy.uri.template.impl.UriTemplateParser.scan(UriTemplateParser.java:89)
at com.damnhandy.uri.template.UriTemplate.parseTemplateString(UriTemplate.java:302)
at com.damnhandy.uri.template.UriTemplate.<init>(UriTemplate.java:154)
at com.damnhandy.uri.template.UriTemplate.fromTemplate(UriTemplate.java:223)

Is there a way to escape colon (:) if query param contains it ?
cc @damnhandy