hapi-server / uri-templates

Repository of tools for URI templates
Apache License 2.0
2 stars 0 forks source link

Case/fmt modifiers not working #27

Closed ericthewizard closed 1 month ago

ericthewizard commented 6 months ago

According to the spec, you can specify the case using modifiers:

fmt=abbrev|full - (optional); default=abbrev case=lc|uc|cap - (optional); default=lc Possibilities: $(b;fmt=abbrev;case=lc): jan, feb, ... $(b;fmt=abbrev;case=uc): JAN, FEB, ... $(b;fmt=abbrev;case=cap): Jan, Feb, ... $(b;fmt=full;case=lc): january, february, ... $(b;fmt=full;case=cap): JANUARY, FEBRUARY, ... $(b;fmt=full;case=uc): January, February, ...

Note: in the spec, "cap" and "uc" are flipped for the full and abbreviated cases.

More importantly, these don't seem to work for me (in Python or JavaScript); here's an example in Python, e.g., lower case:

from URITemplate import URITemplate
from datetime import datetime

month = "$(b;case=lc)"
ut = URITemplate(month)

now = datetime.now()
ut.format(now.isoformat(), now.isoformat())

Gives:

'Feb'

fmt doesn't seem to be working either:

month = "$(b;fmt=full;case=lc)"
ut = URITemplate(month)
ut.format(now.isoformat(), now.isoformat())

Gives:

'Feb'

ericthewizard commented 1 month ago

Have you had a chance to look into this one yet? I thought about making a kludge to get it to work in my copy of the JS version, but that would get us out of sync

jbfaden commented 1 month ago

Hi Eric, sorry I missed this one. I'll have a look in the morning.

jbfaden commented 1 month ago

I have this coded in the Java version, now I need to convert to Python and JavaScript.

ericthewizard commented 1 month ago

I have this coded in the Java version, now I need to convert to Python and JavaScript.

Thanks!

jbfaden commented 1 month ago

It should be ready now, where it's passing the unit tests on Python. Let me know if you see anything weird! I still need to do the JavaScript version, but I assume you are not using it. I'll do that tomorrow morning.

ericthewizard commented 1 month ago

I'm using both the JavaScript and Python versions. I'll test them out tomorrow.

Thanks again!

jbfaden commented 1 month ago

The JavaScript version is also ready. Thanks for pointing out the problem!