URI Templates Redux
Saturday, 28 July 2007
URI Templates -01 is now an Internet-Draft.
After sitting on the spec for a while and trying to figure out an elegant solution to the encoding problem, we decided to take the simple route and see how it sticks. The only encoding that the template spec itself does is for characters that are outside the range of those allowed in URIs. Everything else is application-specifc.
So, for example, this variable;
foo = "/thing?@ <--stüff-->"
with this template:
http://www.example.com/{foo}
will get expanded to this:
http://www.example.com//thing?@%20%3c--st%c3%bcff--%3e
Notice how the space, angle brackets and non-ASCII characters were encoded, while the forward slash, ampersand and question mark were not.
If you want additional encoding, this needs to happen before the variable is fed to the template processor. This allows template processing to be simple and deterministic; you always know what you’re going to get, and pretty much any legal URI can be templated. However, it does put more responsibility on the application to do the encoding to assure that the output is a legal URI.
The hope here is that toolkits will develop sensible patterns for this that will enable template definitions to easily trigger the right pre-encoding. The form that this will take is still up in the air, but I think that’s OK for now.
There are a few other changes; Joe has a diff on his site; discussion welcome on the URI list.
5 Comments
Ian Bicking said:
Sunday, July 29 2007 at 2:00 AM
Mark Nottingham said:
Tuesday, July 31 2007 at 7:19 AM
Ian Bicking said:
Tuesday, July 31 2007 at 8:42 AM
Mike Schinkel said:
Tuesday, July 31 2007 at 9:43 AM
Sam McCall said:
Thursday, August 2 2007 at 4:40 AM