mixdown-router
Advanced tools
Comparing version 4.0.3 to 4.0.4
@@ -6,4 +6,4 @@ var _ = require('lodash'); | ||
if (typeof(global) === 'undefined') { | ||
var global = typeof(window) === 'undefined' ? {} : window; | ||
if (typeof (global) === 'undefined') { | ||
var global = typeof (window) === 'undefined' ? {} : window; | ||
} | ||
@@ -14,3 +14,3 @@ | ||
init: function(options) { | ||
init: function (options) { | ||
this._super(options); | ||
@@ -23,8 +23,8 @@ | ||
// mixdown-router extends this class and overrides this method. | ||
manifest: function(route_table) { | ||
manifest: function (route_table) { | ||
if (route_table) { | ||
this.__route_table__ = route_table; | ||
_.each(this.__route_table__, function(routeObject) { | ||
_.each(routeObject.params, function(param) { | ||
_.each(this.__route_table__, function (routeObject) { | ||
_.each(routeObject.params, function (param) { | ||
if (!(param.regex instanceof RegExp)) { | ||
@@ -43,3 +43,3 @@ param.regex = new RegExp(param.regex); | ||
**/ | ||
url: function(route, params) { | ||
url: function (route, params) { | ||
params = params || {}; | ||
@@ -68,3 +68,3 @@ | ||
// split params into rest/query | ||
_.each(routeObject.params, function(param, key) { | ||
_.each(routeObject.params, function (param, key) { | ||
if (param.kind === 'rest') { | ||
@@ -80,3 +80,3 @@ restParams[key] = param; | ||
_.each(queryParams, function(param, key) { | ||
_.each(queryParams, function (param, key) { | ||
@@ -104,3 +104,3 @@ if (params.hasOwnProperty(key) || param['default']) { | ||
// replace named params with corresponding values and generate uri | ||
_.each(urlSegments, function(segment, i) { | ||
_.each(urlSegments, function (segment, i) { | ||
@@ -119,3 +119,4 @@ // is this a REST segment? | ||
if (pval) { | ||
uri.pathname += '/' + encodeURIComponent(pConfig.regex.replace(/\(.*\)/, pval)).replace(/(%2f)/gi, '/'); | ||
var rx = (pConfig.regex instanceof RegExp) ? pConfig.regex.source : pConfig.regex; | ||
uri.pathname += '/' + encodeURIComponent(rx.replace(/\(.*\)/, pval)).replace(/(%2f)/gi, '/'); | ||
} else if (segment[0] === '?') { | ||
@@ -134,3 +135,3 @@ uri.pathname += '/'; | ||
if (routeObject.cache_buster) { | ||
var cb_key = typeof(routeObject.cache_buster) == 'string' ? routeObject.cache_buster : 'v'; | ||
var cb_key = typeof (routeObject.cache_buster) == 'string' ? routeObject.cache_buster : 'v'; | ||
uri.query[cb_key] = this._options.cache_buster; | ||
@@ -150,3 +151,3 @@ } | ||
**/ | ||
format: function(route, params) { | ||
format: function (route, params) { | ||
var u = this.url(route, params); | ||
@@ -153,0 +154,0 @@ var routeObject = this.manifest()[route]; |
{ | ||
"name": "mixdown-router", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"description": "Router for mixdown.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
70784
1703