About uri.js and querystring.js

2 views
Skip to first unread message

Janne Kuuskeri

unread,
May 27, 2010, 4:16:45 AM5/27/10
to Narwhal and Jack
I noticed a bug in the format() function in the uri module. Where the
original uri had no path the format() was producing double slashes in
the end of the uri. Like so:

http://www.narwhaljs.org/ -> http://www.narwhaljs.org//
/ -> //

I fixed it in

http://github.com/wuher/narwhal/commit/6e08453c0f072a875f944412916249ab3c12e916#diff-0

but as the comment states i'm unsure wether this is the right way to
do it and would like it to be reviewed by somebody who knows the
implementation better.

Another question is about duplicate keys in query strings. Currently
it is ok to pass a query string like "a=1&a=2" for the querystring
module and it will return an object like {a: [1, 2]}. However if I
pass that object back to the querystring module for stringifying it,
it will return string "a%5B%5D=1&a%5B%5D=2" which, after unquoting
becomes "a[]=1&a[]=2" and not "a=1&a=2" as I would have expected.

To me, the square brackets after the key name seem extra. Or, at least
I haven't seen such a notation before. Can somebody enlighten me
please.

Thanks

Kris Kowal

unread,
May 27, 2010, 3:00:10 PM5/27/10
to narw...@googlegroups.com
On Thu, May 27, 2010 at 1:16 AM, Janne Kuuskeri
<janne.k...@gmail.com> wrote:
> I noticed a bug in the format() function in the uri module. Where the
> original uri had no path the format() was producing double slashes in
> the end of the uri. Like so:

Tom, do you have time to integrate this? I scanned it and it looks
good to me, particularly if all those reflexive format/parse tests
pass. We also might consider bringing Isaac on board since he
reimplemented "url" for NodeJS.

Kris Kowal

Reply all
Reply to author
Forward
0 new messages