Permalink
Browse files

set the request path to top level if the given path is null

  • Loading branch information...
laktek committed Mar 17, 2013
1 parent dc428bb commit eaa889c75fd34a8822afd885f0003584808cebed
Showing with 14 additions and 1 deletion.
  1. +2 −1 lib/page_renderer.js
  2. +12 −0 spec/page_renderer.spec.js
View
@@ -205,6 +205,7 @@ module.exports = {
render: function(request_path, output_extension, last_modified, options, callback) {
var self = this;
+ request_path = request_path || "/";
// First, check if request path is a template or content section
if (self.templates.isSection(request_path) || self.contents.isSection(request_path)) {
@@ -221,7 +222,7 @@ module.exports = {
} else if (!err.ignore) {
return callback({ "body": null, "modified": true, "options": { "status": 500, "log": { "message": "[Error] " + err.message } } });
} else if (rendering_steps.length) {
- return rendering_steps.shift().call();
+ return rendering_steps.shift().call();
}
};
View
@@ -75,6 +75,18 @@ describe("setup", function() {
describe("handle rendering request", function() {
+ it("treat null request path as the root path", function() {
+ spyOn(renderer, "serveStatic");
+
+ renderer.templates = { "isSection": function() { return true } };
+ renderer.contents = { "isSection": function() { return true } };
+
+ var spyCallback = jasmine.createSpy();
+ renderer.render(null, ".html", null, {}, spyCallback);
+
+ expect(renderer.serveStatic.mostRecentCall.args[0]).toEqual("/index.html");
+ });
+
it("point the top level request path to index files", function() {
spyOn(renderer, "serveStatic");

0 comments on commit eaa889c

Please sign in to comment.