Fix jsrouting issues

As per #505, I'm refiling this commit against the maintenance branch.
It fixes the previously-broken generation of URLs on the client side.