damnhandy / Handy-URI-Templates

A Java URI Template processor implementing RFC6570
https://damnhandy.github.io/Handy-URI-Templates/
Other
203 stars 37 forks source link

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

Open sandeep14-singh opened 2 years ago

sandeep14-singh commented 2 years ago

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