Minor vertical spacing

This commit is contained in:
Adam Davies 2009-06-10 15:03:02 +09:30
parent 46802f5085
commit a863e01546

View file

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