Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added root url helper

  • Loading branch information...
commit ebacbebcc622f35a55437891d62cfaeaff38655d 1 parent c62ed55
@1602 authored
View
1  .gitignore
@@ -0,0 +1 @@
+node_modules
View
4 lib/railway_routes.js
@@ -49,6 +49,10 @@ Map.prototype.urlHelperName = function (path, action) {
return helperName.join('_');
};
+Map.prototype.root = function (handler, middleware, options) {
+ this.get('/', handler, middleware, options);
+};
+
['get', 'post', 'put', 'delete', 'del', 'all'].forEach(function (method) {
Map.prototype[method] = function (subpath, handler, middleware, options) {
View
13 test/railway_routes_test.js
@@ -122,3 +122,16 @@ it('should allow overwrite path and helper', function (test) {
test.equal(map.pathTo.picture(1602), '/pictures/1602');
test.done();
});
+
+it('should handle root url', function (test) {
+ var paths = [];
+ var map = new routes.Map(fakeApp(paths), fakeBridge());
+ map.root('dashboard#home');
+ test.deepEqual(paths, [
+ [ 'GET', '/', 'dashboard#home' ]
+ ]);
+ test.equal(map.pathTo.root, '/');
+ test.equal(map.pathTo.root(), '/');
+ test.done();
+});
+
Please sign in to comment.
Something went wrong with that request. Please try again.