Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/ExpressRedisCache/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ module.exports = (function () {
/** if it's cached, display cache **/

if ( cache.length ) {
res.contentType(cache[0].type || "text/html");
if (res.contentType) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can avoid this conditional by using res.header which is supported by Express v4.x and Restify.

res.contentType(cache[0].type || "text/html");
} else if (res.setHeader) {
res.setHeader('content-type', cache[0].type || "text/html");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like spaces are being used elsewhere in this project. Would you consider uses spaces instead of tabs for consistency?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, serves me right for doing it in the browser. All fixed.

if(binary){ //Convert back to binary buffer
res.send(new Buffer(cache[0].body, 'base64'));
}else{
Expand Down