Permalink
Browse files

Replacing backslashes with forward slashes for windows machines

  • Loading branch information...
1 parent fc1004e commit 75c672c31472820f51bc2961364eba7917efea6a @DamonOehlman committed Aug 27, 2012
View
@@ -6,7 +6,8 @@ var path = require('path'),
reHiddenFile = /(^|\/)\./,
collect = require('fstream/lib/collect'),
HttpRequestEntry = require('./requestentry'),
- reTrailingSlash = /\/$/;
+ reTrailingSlash = /\/$/,
+ reBackslash = /\\/g;
function AttachmentWriter(props) {
// ensure props have been defined
@@ -107,12 +108,16 @@ AttachmentWriter.prototype._addAttachment = function(name, chunks, size) {
lastIndex = 0;
debug('got buffer of size ' + size + ' for: ' + name);
+
+ // replace back slashes with forward slashes
+ // as loading in from windows tends to cause problems
+ name = name.replace(reBackslash, '/');
chunks.forEach(function(chunk) {
chunk.copy(buffer, lastIndex);
lastIndex += chunk.length;
});
-
+
this._newAttachments[name] = {
content_type: mime.lookup(name),
data: buffer.toString('base64')
@@ -0,0 +1 @@
+helloWorld
@@ -0,0 +1 @@
+Another test
View
@@ -29,6 +29,7 @@ describe('upload tests', function() {
it('should be able upload a directory containing a single file', uploadAndCheck('single'));
it('should be able to upload a directory with multiple files', uploadAndCheck('multiple'));
it('should be able to upload a directory with binary files', uploadAndCheck('binary'));
+ it('should be able to traverse a directory and upload all files', uploadAndCheck('traverse'));
});
describe('short format', function() {

0 comments on commit 75c672c

Please sign in to comment.