hal4j / uritemplate

Java implementation of RFC 6570 (URI template)
Apache License 2.0
3 stars 0 forks source link

Prefix modifier for complex value types #9

Closed C06A closed 1 year ago

C06A commented 1 year ago

It seems this project doesn't handle the Prefix modifier if the value is a List or Map. Simple String value handled correctly.

Also, from the Appendix 1, it seems modifiers Prefix and Explode can be combined at least in form {var*:3}.

ivan-gammel commented 1 year ago

According to specification:

2.4.1. Prefix values A prefix modifier indicates that the variable expansion is limited to a prefix of the variable's value string. Prefix modifiers are often used to partition an identifier space hierarchically, as is common in reference indices and hash-based storage. It also serves to limit the expanded value to a maximum number of characters. Prefix modifiers are not applicable to variables that have composite values.

Appendix A defines parsing rules, not how the values should be processed. In my understanding this means that {var*:3} is syntactically correct, but prefix part is ignored per 2.4.1.

ivan-gammel commented 1 year ago

Relevant conversation: https://github.com/uri-templates/uritemplate-test/pull/27#issuecomment-24909382

C06A commented 1 year ago

I am not sure how this issue related. It is 10 years old and pointed problems with the RFC at the time. I think it is perfectly reasonable to apply prefix to each value and this is what I expecting. In case of leading 0s in prefix modifier -- this is a very interesting case. Because interpretation of string as integer is very much platform-specific, I think it makes sense to interpret the string as decimal integer (no characters other then digits and ignoring leading 0s). Should be spelled out in the RFC.

C06A commented 1 year ago

Thank you for pointing 2.4.1 description. I overlooked it. I guess the point is that in case of both modifiers present one (*) applicable to the composit values and another (prefix) -- to simple values. Kind of make sense.