Skip to content

Commit

Permalink
Only run fast-render for HTML pages
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoda committed May 10, 2015
1 parent 61f59ae commit 9203dcb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var Fiber = Npm.require('fibers');
FastRender._onAllRoutes = [];

var fastRenderRoutes = Picker.filter(function(req, res) {
return IsAppUrl(req.url);
return IsAppUrl(req);
});
fastRenderRoutes.middleware(Npm.require('connect').cookieParser());

Expand Down
17 changes: 11 additions & 6 deletions lib/server/utils.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
// meteor algorithm to check if this is a meteor serving http request or not
IsAppUrl = function (url) {
if (url === '/favicon.ico' || url === '/robots.txt')
IsAppUrl = function (req) {
var url = req.url
if(url === '/favicon.ico' || url === '/robots.txt') {
return false;
}

// NOTE: app.manifest is not a web standard like favicon.ico and
// robots.txt. It is a file name we have chosen to use for HTML5
// appcache URLs. It is included here to prevent using an appcache
// then removing it from poisoning an app permanently. Eventually,
// once we have server side routing, this won't be needed as
// unknown URLs with return a 404 automatically.
if (url === '/app.manifest')
if(url === '/app.manifest') {
return false;
}

// Avoid serving app HTML for declared routes such as /sockjs/.
if (RoutePolicy.classify(url))
if(RoutePolicy.classify(url)) {
return false;
}

// we currently return app HTML on all URLs by default
return true;
// we only need to support HTML pages only
// this is a check to do it
return /html/.test(req.headers['accept']);
};
8 changes: 6 additions & 2 deletions tests/server/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,12 @@ Tinytest.add('integration - error inside a null publication', function(test) {
var urlResolve = Npm.require('url').resolve;
function getFRData(path) {
var url = urlResolve(process.env.ROOT_URL, path);
var res = HTTP.get(url);

var options = {
headers: {
"Accept": "text/html"
}
};
var res = HTTP.get(url, options);

var encodedData = res.content.match(/data">(.*)<\/script/)[1];
return InjectData._decode(encodedData)['fast-render-data'];
Expand Down

0 comments on commit 9203dcb

Please sign in to comment.