Are you sure? You add a slash at the end of the url.
return url + (query.length ? '?' + query.join('&') : '') + '/';    
>>  foo?query1=1&query2=2/

I would made a bid for a line 296