Permalink
Browse files

Removed require("connect/utils")

  • Loading branch information...
1 parent c81b65a commit 042229f0c11a25c2c220c208d922ba604cacfebc @tj tj committed Jul 28, 2010
Showing with 20 additions and 4 deletions.
  1. +20 −4 lib/connect-form.js
View
@@ -9,8 +9,7 @@
* Module dependencies.
*/
-var utils = require('connect/utils'),
- formidable = require('formidable');
+var formidable = require('formidable');
/**
* Setup form with the given `options`.
@@ -57,7 +56,7 @@ module.exports = function(options){
if (formRequest(req)) {
var callback = function(){},
form = req.form = new formidable.IncomingForm;
- utils.merge(form, options);
+ merge(form, options);
form.complete = function(fn){ callback = fn; };
form.parse(req, function(){
callback.apply(this, arguments);
@@ -75,10 +74,27 @@ module.exports = function(options){
* @api private
*/
-function formRequest(req){
+function formRequest(req) {
return req.body === undefined
&& (req.method === 'POST'
|| req.method === 'PUT')
&& (req.headers['content-type'].indexOf('multipart/form-data') >= 0
|| req.headers['content-type'].indexOf('urlencoded') >= 0);
+}
+
+/**
+ * Merge object `b` with object `a`.
+ *
+ * @param {Object} a
+ * @param {Object} b
+ * @return {Object} a
+ * @api private
+ */
+
+function merge(a, b) {
+ var keys = Object.keys(b);
+ for (var i = 0, len = keys.length; i < len; ++i) {
+ a[keys[i]] = b[keys[i]];
+ }
+ return a;
}

0 comments on commit 042229f

Please sign in to comment.