Closed fgilbert closed 4 years ago
The important part from the RFC is in section 2.3. Variables:
varname = varchar *( ["."] varchar ) varchar = ALPHA / DIGIT / "_" / pct-encoded
so variable names have to start with either a character, digit, underscore or any percent-encoded character (pct-encoded = "%" HEXDIG HEXDIG
).
While percent-encoded characters would be your best option, the regex in UriTemplate
doesn't support it right now: it's ([\w\,]+)
(with \w
being short for [a-zA-Z_0-9]
). Thus, the implementation really is this at the moment:
varname = *( varchar ) varchar = ALPHA / DIGIT / "_"
I've created #475 for better support of RFC compliant variable names
Superceded by #475.
Hi, I would like to create an URI template with a variable name starts with $ character. It doesn't work when I instanciate
UriTemplate
with a template string like this : http://localhost/foo/bar{?$filter} But it works with a base URI ( http://localhost/foo/bar) and template variable object, see unit tests.This is due to the fact that the variable RegExp
\{([\?\&#\/]?)([\w\,]+)\}
used in theUriTemplate(String)
constructor doesn't accept $ character. However, according to RFC 6570 - URI Template (http://tools.ietf.org/html/rfc6570), §2.2 Expressions :Unit Test KO with template String -> IllegalArgumentException :
Unit Test OK with TemplateVariable Object :
Thanks