connect-preprocess
Advanced tools
Comparing version 0.1.1 to 0.1.2
24
index.js
@@ -19,3 +19,3 @@ module.exports = function( options ) { | ||
var ext = content_type ? mime.extension( content_type ) : req.url.match( /(\.\w+)\??.*$/ ); | ||
return this.accept.indexOf( ext ) >= 0; | ||
return res.statusCode == 200 && this.accept.indexOf( ext ) >= 0; | ||
} | ||
@@ -49,4 +49,5 @@ }); | ||
res.write = function( string , encoding ) { | ||
encoding = encoding || 'utf-8'; | ||
if (string !== undefined) { | ||
var body = string instanceof Buffer ? string.toString( encoding ) : string; | ||
var body = (Buffer.isBuffer( string ) ? string.toString( encoding ) : string); | ||
if (res._headers && $preprocessor._accepts( req , res )) { | ||
@@ -63,9 +64,16 @@ res.push( body ); | ||
res.end = function( string , encoding ) { | ||
var body = $preprocessor.engine( res.data ); | ||
if (res.data !== undefined && !res._header) { | ||
res.setHeader( 'Content-Length' , Buffer.byteLength( body , encoding )); | ||
encoding = encoding || 'utf-8'; | ||
if (res.data && $preprocessor._accepts( req , res )) { | ||
var body = $preprocessor.engine( res.data ); | ||
if (res.data !== undefined && !res._header) { | ||
res.setHeader( 'Content-Length' , Buffer.byteLength( body , encoding )); | ||
} | ||
res.data = ''; | ||
restore(); | ||
res.end( body , encoding ); | ||
} | ||
res.data = ''; | ||
restore(); | ||
res.end( body , encoding ); | ||
else { | ||
restore(); | ||
next(); | ||
} | ||
}; | ||
@@ -72,0 +80,0 @@ |
{ | ||
"name": "connect-preprocess", | ||
"description": "flexible preprocessor middleware for connect / express.", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/elnarddogg/connect-preprocess", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5962
66