Skip to content
Browse files

Support subapps

  • Loading branch information...
1 parent 712b2bc commit da601d71ec30d88ba5ada72faef8dea1231548ad @1602 committed Oct 31, 2012
Showing with 15 additions and 3 deletions.
  1. +9 −1 lib/railway_routes.js
  2. +3 −2 package.json
  3. +3 −0 test/spec_helper.js
View
10 lib/railway_routes.js
@@ -151,6 +151,8 @@ Map.prototype.root = function (handler, middleware, options) {
* Add path helper to `pathTo` collection
*/
Map.prototype.addPath = function (templatePath, action, helperName) {
+ var app = this.app;
+
if (templatePath instanceof RegExp) {
// TODO: think about adding to `path_to` routes by reg ex
return;
@@ -200,7 +202,13 @@ Map.prototype.addPath = function (templatePath, action, helperName) {
path = hook(path);
});
}
- return path;
+ var appprefix = '';
+ if (app.path) {
+ appprefix = app.path();
+ } else {
+ appprefix = app.set('basepath') || '';
+ }
+ return appprefix + path;
}.bind(this);
this.pathTo[helperName].toString = function () {
return this.pathTo[helperName]();
View
5 package.json
@@ -3,7 +3,7 @@
"name": "railway-routes",
"description": "Resourceful routing for ExpressJS, ruby-on-rails 2 style",
"tags": "express, routing, ror, rails, railway",
- "version": "0.0.7",
+ "version": "0.0.8",
"homepage": "http://railwajs.com/routing.html",
"repository": {
"type": "git",
@@ -20,6 +20,7 @@
"express": "3.x"
},
"devDependencies": {
- "nodeunit": "*"
+ "nodeunit": "*",
+ "semicov": "latest"
}
}
View
3 test/spec_helper.js
@@ -1,3 +1,6 @@
+require('semicov').init('lib', 'Railway Routes'); // 'lib' is name of dir with code
+process.on('exit', require('semicov').report);
+
var group_name = false, EXT_EXP;
function it(should, test_case) {

0 comments on commit da601d7

Please sign in to comment.
Something went wrong with that request. Please try again.