|
|
@@ -165,6 +165,9 @@ module.exports = function(crowi, app) {
|
|
|
var path = path || getPathFromRequest(req);
|
|
|
var options = {};
|
|
|
|
|
|
+ // FIXME: せっかく getPathFromRequest になってるのにここが生 params[0] だとダサイ
|
|
|
+ var isMarkdown = req.params[0].match(/.+\.md$/) || false;
|
|
|
+
|
|
|
res.locals.path = path;
|
|
|
|
|
|
// pageShow は /* にマッチしてる最後の砦なので、creatableName でない routing は
|
|
|
@@ -179,8 +182,7 @@ module.exports = function(crowi, app) {
|
|
|
.then(function(page) {
|
|
|
debug('Page found', page._id, page.path);
|
|
|
|
|
|
- // FIXME: せっかく getPathFromRequest になってるのにここが生 params[0] だとダサイ
|
|
|
- if (req.params[0].match(/.+\.md$/)) {
|
|
|
+ if (isMarkdown) {
|
|
|
res.set('Content-Type', 'text/plain');
|
|
|
return res.send(page.revision.body);
|
|
|
}
|
|
|
@@ -191,6 +193,10 @@ module.exports = function(crowi, app) {
|
|
|
return res.redirect(encodeURI(path));
|
|
|
}
|
|
|
|
|
|
+ if (isMarkdown) {
|
|
|
+ return res.redirect('/');
|
|
|
+ }
|
|
|
+
|
|
|
debug('Catch pageShow', err);
|
|
|
return renderPage(null, req, res);
|
|
|
});
|