Supporting alternate query string separators

2 views
Skip to first unread message

aparajita

unread,
May 18, 2007, 8:08:51 AM5/18/07
to Prototype: Core
Hi,

The HTML 4 specification recommends that a semicolon be used as the
separator for query string parameters because of the issues with
encoding '&' in link urls (see http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2).

In view of this, it would be very nice indeed if an optional separator
param were added to any functions that ultimately would call
Hash#toQueryString. (Especially since my software uses a semicolon and
not &).

Thank you,

- Aparajita

Mislav Marohnić

unread,
May 18, 2007, 9:30:22 AM5/18/07
to prototy...@googlegroups.com
On 5/18/07, aparajita <apar...@aparajitaworld.com> wrote:

The HTML 4 specification recommends that a semicolon be used as the
separator for query string parameters because of the issues with
encoding '&' in link urls (see http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2).

The String#toQueryParams method already accepts a separator argument:
http://prototypejs.org/api/string/toQueryParams

I guess it may be available for Hash.toQueryString, too. And, since we recommend keeping params as hashes in your code (not strings) before you pass them to Ajax.Requests, I guess we need an option for Ajax to serialize those hashes with an alternate separator, too.

aparajita

unread,
May 20, 2007, 6:46:13 AM5/20/07
to Prototype: Core
> The String#toQueryParams method already accepts a separator argument

I know, but there are other places where & is assumed.


> I guess it may be available for Hash.toQueryString, too. And, since we
> recommend keeping params as hashes in your code (not strings) before you
> pass them to Ajax.Requests, I guess we need an option for Ajax to serialize
> those hashes with an alternate separator, too.

Because the use of & and Hash.toQueryString is scattered throughout
prototype, you may want to provide some kind of global setting for the
query parameter separator. This would allow you to get the desired
behavior without having to change the function interface for every
function that hard codes '&' or that might eventually call
Hash.toQueryString or String#toQueryParams.

- Aparajita

Mislav Marohnić

unread,
May 20, 2007, 7:16:57 AM5/20/07
to prototy...@googlegroups.com
On 5/20/07, aparajita <apar...@aparajitaworld.com> wrote:

Because the use of & and Hash.toQueryString is scattered throughout
prototype, you may want to provide some kind of global setting for the
query parameter separator.

Smart! Actually I thought about it in January, but from then I completely forgot. Can you open up a ticket for this? You don't have to make a patch, just describe the idea in the description. That way I would have a TODO item (kind of) and you get informed when it gets in core.

aparajita

unread,
May 20, 2007, 11:01:44 PM5/20/07
to Prototype: Core
> Smart! Actually I thought about it in January, but from then I completely
> forgot. Can you open up a ticket for this? You don't have to make a patch,
> just describe the idea in the description. That way I would have a TODO item
> (kind of) and you get informed when it gets in core.

I just added a ticket, and I look forward to seeing it in the core.
Thanks for listening.

- Aparajita

Reply all
Reply to author
Forward
0 new messages