Find function can not generate right URL!

0 views
Skip to first unread message

dlee

unread,
Dec 18, 2007, 9:40:47 PM12/18/07
to Jester JS
In Prototype 1.6, find function can not generate right URL. The final
URL is like this:
http://localhost:3000/books/:id.json?id=1

This problem is because the implementation of _interpolate function.
In _interpolate function, the for...in loop can not find id param,
this is because Prototype has modified Object's function, this
modifition has bad effect to for...in loop. To solve this problem, we
must use Prototype's each function to do the same thing.

I modified _interpolate function like this:

_interpolate: function(string, params) {
var result = string;

if (params) {
params.each(function(pair) {
var re = new RegExp(":" + pair.key, "g");
if (result.match(re)) {
result = result.replace(re, pair.value);
params.unset(pair.key);
}
});
}

return result;
},

This time it works, the final URL is like this:
http://localhost:3000/books/1.json?id=1

I use Jester 1.5, Prototype 1.6.0.1, Rails 2.0.1 and Firefox 2.0.0.11
on Windows 2000 Professional SP4.

Eric Mill

unread,
Dec 19, 2007, 11:07:55 AM12/19/07
to Jester JS
OK, bug logged. I'm going to have to do a comprehensive Prototype 1.6
update real soon. Thanks for the heads up on this, and the informal
patch.

-- Eric

scott_per

unread,
Jan 29, 2008, 1:14:17 AM1/29/08
to Jester JS
I can verify both this bug, using Prototype 1.6, and the fix.

--scott
> > on Windows 2000 Professional SP4.- Hide quoted text -
>
> - Show quoted text -

Eric Mill

unread,
Feb 22, 2008, 1:45:09 PM2/22/08
to Jester JS
I entered this into the issue tracker:
http://code.google.com/p/jester-js/issues/detail?id=2

Expect action on this one promptly.

-- Eric
Reply all
Reply to author
Forward
0 new messages