Skip to content

Commit

Permalink
fix to transitional route detection using hasOwnProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
nateps committed Jul 28, 2012
1 parent c3133cb commit 188dfa5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/browser.js
Expand Up @@ -9,6 +9,7 @@ require.modules.mime = function() {}
var Route = require('express/lib/router/route')
, History = require('./History')
, router = module.exports = require('./router')
, isTransitional = router._isTransitional

router.setup = setup

Expand All @@ -29,7 +30,7 @@ function setup(app, createPage, onRoute) {
app[method] = function(pattern, callback, callback2) {
var callbacks = {onRoute: onRoute}

if (pattern.from && pattern.to) {
if (isTransitional(pattern)) {
var from = pattern.from
, to = pattern.to
, forward = pattern.forward || callback.forward || callback
Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
@@ -1,6 +1,7 @@
var ExpressRouter = require('express/lib/router')
, router = module.exports = require('./router')
, mapRoute = router._mapRoute
, isTransitional = router._isTransitional

router.setup = setup

Expand Down Expand Up @@ -60,7 +61,7 @@ function setup(app, createPage, onRoute) {
, callback = route[2]

// Create route for 'to' callback of transitional route
if (pattern.from && pattern.to) {
if (isTransitional(pattern)) {
var from = pattern.from
, to = pattern.to
callback = pattern.forward || callback.forward || callback
Expand Down
3 changes: 3 additions & 0 deletions lib/router.js
Expand Up @@ -11,6 +11,9 @@ exports.set = function(setting, value) {
exports.get = function(setting) {
return settings[setting]
}
exports._isTransitional = function(pattern) {
return pattern.hasOwnProperty('from') && pattern.hasOwnProperty('to')
}

function mapRoute(from, params) {
var i, path, queryString, url
Expand Down

0 comments on commit 188dfa5

Please sign in to comment.