Skip to content

Commit

Permalink
Merge pull request #135 from joegoldbeck/master
Browse files Browse the repository at this point in the history
Throw error when path doesn't begin with a leading slash
  • Loading branch information
arunoda committed Sep 9, 2015
2 parents 77c7b69 + 5e09b1c commit 05a2699
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ fastRenderRoutes.middleware(function(req, res, next) {

// handling specific routes
FastRender.route = function route(path, callback) {
if(path.indexOf('/') !== 0){
throw new Error('Error: path (' + path + ') must begin with a leading slash "/"')
}
fastRenderRoutes.route(path, FastRender.handleRoute.bind(null, callback));
};

Expand Down
9 changes: 9 additions & 0 deletions tests/server/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ Tinytest.add('integration - error inside a null publication', function(test) {
test.equal(data.collectionData, {});
});

Tinytest.add('integration - when path has no leading slash', function(test) {
var path = Random.id();

test.throws(function(){
FastRender.route(path, function() {
});
}, 'Error: path (' + path + ') must begin with a leading slash "/"');
});

var urlResolve = Npm.require('url').resolve;
function getFRData(path) {
var url = urlResolve(process.env.ROOT_URL, path);
Expand Down

0 comments on commit 05a2699

Please sign in to comment.