Re: A URL API

On Fri, Sep 17, 2010 at 2:39 PM, Garrett Smith <dhtmlkitchen@gmail.com> wrote:
> On 9/17/10, Adam Barth <w3c@adambarth.com> wrote:
>> On Fri, Sep 17, 2010 at 11:57 AM, Garrett Smith <dhtmlkitchen@gmail.com>
>> wrote:
>>> Where is Dictionary defined?
>>
>> It might not be defined yet.
>
> You don't know if it is defined or not? Makes no sense at all.

That's correct.  I wrote the word Dictionary there, and I had a clear
idea what I had in mind, but I'm not sure whether that idea has been
written down anywhere.

>>> What are the values for searchParameters
>>> -- can they be strings or are they only array;
>>
>> In JavaScript, I'd imagine implementing them as a normal JavaScript
>> object with property names that correspond to the URL parameters.
>>
>>> var x = new URL("http://example.net/?title=foo&title=bar);
>>> x.searchParameters.title;
>>>
>>> ?
>>
> SO you're saying that
>
> x.searchParameters.title is an object with property names that
> correspond to URL parameters -- again -- makes no sense. It looks like
> you didn't understand question so I'll rephrase and elaborate:
>
> If, for each parameter, the dictionary gets a key entry with the value
> corresponding to the parameter name, then what is the value associated
> with that key. Referring again to the xample, what would be the value
> of x.searchParameters.title -- an Array?

The value would be a string, such as "foo" or "bar".  In the example
you gave, there are two parameters with the name title.  The
specification will say which of the two values will show up in the
dictionary, but I haven't studied the question of which one yet.

> And what of the prototype of that Dictionary?

Object.prototype.

> Another object with nonstandard catchall behavior?

No.

> No thanks on that. What is the value of
> x.searchParameters.valueOf? undefined? A function? Null?

Object.prototype.valueOf

> Storage also has live-Dictionary features but does not use Dictionary.
> Seems like a common interface.
>
> <http://dev.w3.org/html5/webstorage/#storage-0>
>
> get/set/remove/clear all make sense there, but so do batch adds, e.g.
> setItems(obj).

Rather than invent a new dictionary type, I think it make sense to use
the native one in the language (which in JavaScript is called Object),
which connects up with why modifying the dictionary doesn't mutate the
underlying URL.

> Working with parameter values can be a tricky if, say, the the program
> wants to remove one value for title and keep another. If URI has a
> getParameterMap then it should either be live or it should have a
> setParameterMap method. The one way API makes no sense.

I don't think we need to tackle that problem in the first version.
HTML has a very nice way of constructing URLs with query parameters
called the form element.

Adam

Received on Friday, 17 September 2010 23:41:56 UTC