Comparing version 0.0.12 to 0.0.13
@@ -55,9 +55,9 @@ // TODO: | ||
var nfiles = 0, nfields = 0, nparts = 0, nends = 0, | ||
finished = false; | ||
var nfiles = 0, nfields = 0, nends = 0, finished = false; | ||
this._needDrain = false; | ||
this._pause = false; | ||
this._cb = undefined; | ||
this._nparts = 0; | ||
this._boy = boy; | ||
@@ -82,3 +82,3 @@ var parserCfg = { | ||
this.parser.on('part', function onPart(part) { | ||
if (++nparts > partsLimit) { | ||
if (++self._nparts > partsLimit) { | ||
self.parser.removeListener('part', onPart); | ||
@@ -111,6 +111,15 @@ self.parser.on('part', skipParts); | ||
for (i = 0, len = parsed.length; i < len; ++i) { | ||
if (RE_NAME.test(parsed[i][0])) | ||
if (RE_NAME.test(parsed[i][0])) { | ||
fieldname = parsed[i][1]; | ||
else if (RE_FILENAME.test(parsed[i][0])) | ||
try { | ||
fieldname = jsencoding.TextDecoder('utf8') | ||
.decode(new Buffer(fieldname, 'binary')); | ||
} catch(e) {} | ||
} else if (RE_FILENAME.test(parsed[i][0])) { | ||
filename = parsed[i][1]; | ||
try { | ||
filename = jsencoding.TextDecoder('utf8') | ||
.decode(new Buffer(filename, 'binary')); | ||
} catch(e) {} | ||
} | ||
} | ||
@@ -212,3 +221,7 @@ } else | ||
Multipart.prototype.end = function() {}; | ||
Multipart.prototype.end = function() { | ||
var self = this; | ||
if (this._nparts === 0) | ||
process.nextTick(function() { self._boy.emit('end'); }); | ||
}; | ||
@@ -215,0 +228,0 @@ function skipParts(part) { |
{ "name": "busboy", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"author": "Brian White <mscdex@mscdex.net>", | ||
@@ -7,3 +7,3 @@ "description": "A streaming parser for HTML form data for node.js", | ||
"dependencies": { | ||
"dicer": "0.1.5", | ||
"dicer": "0.1.6", | ||
"readable-stream": "1.1.x" | ||
@@ -10,0 +10,0 @@ }, |
@@ -59,3 +59,3 @@ Description | ||
</form>\ | ||
</body>'); | ||
</body></html>'); | ||
} | ||
@@ -166,3 +166,3 @@ }).listen(8000, function() { | ||
</form>\ | ||
</body>'); | ||
</body></html>'); | ||
} | ||
@@ -191,3 +191,3 @@ }).listen(8000, function() { | ||
* **file**(< _string_ >fieldname, < _ReadableStream_ >stream, < _string_ >filename, < _string_ >transferEncoding, < _string_ >mimeType) - Emitted for each new file form field found. `transferEncoding` contains the 'Content-Transfer-Encoding' value for the file stream. `mimeType` contains the 'Content-Type' value for the file stream. | ||
* **file**(< _string_ >fieldname, < _ReadableStream_ >stream, < _string_ >filename, < _string_ >transferEncoding, < _string_ >mimeType) - Emitted for each new file form field found. `transferEncoding` contains the 'Content-Transfer-Encoding' value for the file stream. `mimeType` contains the 'Content-Type' value for the file stream. Notice that when no file is attached to the field, (typeof filename === 'undefined'), the stream is 0-length but still requires draining to signal that the event was handled, otherwise the 'end' event will not fire. call stream.resume() to drain the stream. | ||
@@ -194,0 +194,0 @@ * **field**(< _string_ >fieldname, < _string_ >value, < _boolean_ >valueTruncated, < _boolean_ >fieldnameTruncated) - Emitted for each new non-file field found. |
@@ -69,2 +69,9 @@ var Multipart = require('../lib/types/multipart'), | ||
}, | ||
{ source: [ | ||
'' | ||
], | ||
boundary: '----WebKitFormBoundaryTB2MiQ36fnSJlrhY', | ||
expected: [], | ||
what: 'No fields and no files' | ||
}, | ||
]; | ||
@@ -134,3 +141,3 @@ | ||
process.on('exit', function() { | ||
assert(t === tests.length, 'Only ran ' + t + '/' + tests.length + ' tests'); | ||
assert(t === tests.length, makeMsg('_exit', 'Only finished ' + t + '/' + tests.length + ' tests')); | ||
}); |
@@ -11,3 +11,4 @@ var UrlEncoded = require('../lib/types/urlencoded'), | ||
var group = path.basename(__filename, '.js') + '/'; | ||
var t = 0, | ||
group = path.basename(__filename, '.js') + '/'; | ||
@@ -17,3 +18,3 @@ var parsedConType; | ||
[ | ||
var tests = [ | ||
{ source: ['foo'], | ||
@@ -131,3 +132,10 @@ expected: [['foo', undefined, false, false]], | ||
}, | ||
].forEach(function(v) { | ||
]; | ||
function next() { | ||
if (t === tests.length) | ||
return; | ||
var v = tests[t]; | ||
var busboy = new EventEmitter(), ue, results = []; | ||
@@ -137,2 +145,23 @@ busboy.on('field', function(key, val, valTrunc, keyTrunc) { | ||
}); | ||
busboy.on('end', function() { | ||
assert.deepEqual(results.length, | ||
v.expected.length, | ||
makeMsg(v.what, 'Parsed result count mismatch. Saw ' | ||
+ results.length | ||
+ '. Expected: ' + v.expected.length)); | ||
var i = 0; | ||
results.forEach(function(result) { | ||
assert.deepEqual(result, | ||
v.expected[i], | ||
makeMsg(v.what, | ||
'Result mismatch:\nParsed: ' + inspect(result) | ||
+ '\nExpected: ' + inspect(v.expected[i])) | ||
); | ||
++i; | ||
}); | ||
++t; | ||
next(); | ||
}); | ||
var cfg = { | ||
@@ -149,23 +178,11 @@ limits: v.limits, | ||
ue.end(); | ||
} | ||
next(); | ||
assert.deepEqual(results.length, | ||
v.expected.length, | ||
makeMsg(v.what, 'Parsed result count mismatch. Saw ' | ||
+ results.length | ||
+ '. Expected: ' + v.expected.length)); | ||
var i = 0; | ||
results.forEach(function(result) { | ||
assert.deepEqual(result, | ||
v.expected[i], | ||
makeMsg(v.what, | ||
'Result mismatch:\nParsed: ' + inspect(result) | ||
+ '\nExpected: ' + inspect(v.expected[i])) | ||
); | ||
++i; | ||
}); | ||
}); | ||
function makeMsg(what, msg) { | ||
return '[' + group + what + ']: ' + msg; | ||
} | ||
process.on('exit', function() { | ||
assert(t === tests.length, makeMsg('_exit', 'Only finished ' + t + '/' + tests.length + ' tests')); | ||
}); |
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
662291
5247
+ Addeddicer@0.1.6(transitive)
- Removeddicer@0.1.5(transitive)
Updateddicer@0.1.6