##// END OF EJS Templates
extra params in pyroutes now generate GET params
marcink -
r3403:07f41930 beta
parent child Browse files
Show More
@@ -302,12 +302,25 b' var pyroutes = (function() {'
302 }
302 }
303 if (matchlist.hasOwnProperty(route_name)) {
303 if (matchlist.hasOwnProperty(route_name)) {
304 var route = matchlist[route_name];
304 var route = matchlist[route_name];
305 // param substitution
305 for(var i=0; i < route[1].length; i++) {
306 for(var i=0; i < route[1].length; i++) {
306
307
307 if (!params.hasOwnProperty(route[1][i]))
308 if (!params.hasOwnProperty(route[1][i]))
308 throw new Error(route[1][i] + ' missing in "' + route_name + '" route generation');
309 throw new Error(route[1][i] + ' missing in "' + route_name + '" route generation');
309 }
310 }
310 result = sprintf(route[0], params);
311 result = sprintf(route[0], params);
312
313 var ret = [];
314 //extra params => GET
315 for(param in params){
316 if (route[1].indexOf(param) == -1){
317 ret.push(encodeURIComponent(param) + "=" + encodeURIComponent(params[param]));
318 }
319 }
320 var _parts = ret.join("&");
321 if(_parts){
322 result = result +'?'+ _parts
323 }
311 }
324 }
312
325
313 return result;
326 return result;
General Comments 0
You need to be logged in to leave comments. Login now