diff --git a/lib/javascripts/routes-min.js b/lib/javascripts/routes-min.js index 14684ed..5cba819 100644 --- a/lib/javascripts/routes-min.js +++ b/lib/javascripts/routes-min.js @@ -10,7 +10,7 @@ if(!options.includeSlash&&path.match(/.+\/$/)){path=path.slice(0,-1);} if(!options.onlyPath){var portString=options.port?':'+options.port:'';path=[options.protocol,options.host,portString,path].join('')} var leftOvers=[];iterate(params,function(k,v){leftOvers.push(k+'='+v);});if(leftOvers.length>0){path=path+'?'+leftOvers.join('&');} if(options.escape){path=encodeURI(path);} -return path;},toString:function(){return this.segments.join('');}};Route.Segment=function(value,type,optional){this.value=value;this.type=type||'static';this.optional=(typeof optional==='boolean'?optional:true);};Route.Segment.prototype={isDynamic:function(){return this.type==='dynamic'||this.type==='path';},toString:function(){if(this.type==='dynamic'){return':'+this.value;}else if(this.type==='path'){return'*'+this.value;}else{return this.value;}},equal:function(other){return other.constructor===this.constructor&&other.value===this.value&&other.type===this.type&&other.optional===this.optional;}};Route.createSegment=function(s,optional){if(s.match(/^[\/;?.]$/)){return new Route.Segment(s,'divider',optional);}else if(s.indexOf(':')===0){return new Route.Segment(s.slice(1),'dynamic',optional);}else if(s.indexOf('*')===0){return new Route.Segment(s.slice(1),'path',optional);}else{return new Route.Segment(s,'static',optional);}};Route.S=Route.createSegment;var Routes=[];Routes.named=[];Routes.defaultParams={action:'index'};Routes.defaultOptions={escape:true,port:window.location.port,protocol:window.location.protocol+'//',host:window.location.hostname};Routes.extractNamed=function(){var route;for(var i=0;icount){params[route.segments[i].value]=arguments[count];} count++;}}}