Minor vertical spacing

master
Adam Davies 2009-06-10 15:03:02 +09:30
parent 46802f5085
commit a863e01546
1 changed files with 17 additions and 17 deletions

View File

@ -41,14 +41,14 @@
this.params = params || {};
this.name = name;
};
Route.prototype = {
generate: function(pa, op){
var options = merge(Routes.defaultOptions, op || {});
var params = options.noDefaults ? merge({}, pa || {}) : merge(Routes.defaultParams, pa || {});
var path = '';
var hasParam = false;
var routeMatch = true;
iterate(this.params, function(k,v){
@ -65,11 +65,11 @@
return;
}
});
if (!routeMatch) {
return false;
}
try {
iterate(this.segments, function(segment, index, segments){
switch (segment.type) {
@ -116,37 +116,37 @@
}
}
}
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){
@ -154,7 +154,7 @@
this.type = type || 'static';
this.optional = (typeof optional === 'boolean' ? optional : true);
};
Route.Segment.prototype = {
isDynamic: function(){
return this.type === 'dynamic' || this.type === 'path';
@ -170,7 +170,7 @@
},
equal: function(other){
return other.constructor === this.constructor && other.value === this.value &&
other.type === this.type && other.optional === this.optional;
other.type === this.type && other.optional === this.optional;
}
};
@ -251,7 +251,7 @@
}
}
};
Routes.generate = function(params, options){
params = params || {};
var path;
@ -263,11 +263,11 @@
}
return false;
};
Routes.named.toString = Routes.toString = function(){
return this.join(', ');
};
window['Route'] = Route;
window['Routes'] = Routes;