Re: URI Templates - optional variables?

On 8/10/07, Mark Nottingham <mnot@mnot.net> wrote:
>
> On 02/08/2007, at 8:02 AM, Roy T. Fielding wrote:
>
> > I still think that URI templates need to define a syntax for
> > defaulting and other common string substitutions, even if the
> > initial authors have no need of it.
>
> It's not that we don't have need of it, it's just that we haven't got
> a good answer for it yet, and we've been focused on the encoding
> issue. I, for one, am very open to suggestions.

True, but as I dig back into URI Templates I realize that
these substitutions actually *fix* the encoding issue.

Very quickly, with a rule like:

         {,&:name,age,sex,location} = "name=Fred&age=41&location=USA"

we can avoid worrying about whether or not to escape
'&', '=', and '?' in the values of name, age, sex, and location.
That was a major stumbling block and I've now put together enough
examples to convince myself that we can *never* guess correctly,
even if we take a URI component by component. With a set of templating
rules like the ones Roy has suggested we can get away with
a simple encoding rule: everything outside 'pchar' should be percent-encoded.
(Actually, if the values are unicode then convert to utf-8 and then
  percent-encode values outside pchar).

   Thanks,
   -joe

-- 
Joe Gregorio        http://bitworking.org

Received on Friday, 5 October 2007 18:19:19 UTC