Skip to content

Commit

Permalink
A few more bugfixes in parsing.
Browse files Browse the repository at this point in the history
hrishikeshs committed Jun 8, 2014
1 parent 5a8bc1d commit 4a65b14
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -17,14 +17,14 @@ Mongoman.DocumentsController = Ember.ArrayController.extend({
var keys = str.match(/['"]?[a-zA-Z0-9_\"\s\']+['"]?:\s+/g);
if (keys) {
for (var i = 0, j = keys.length; i < j; i++) {
str = str.replace(keys[i],'"' + keys[i].split(':')[0].trim() + '":' );
var newKey = '"' + keys[i].split(':')[0].trim() + '":';
str = str.replace(keys[i], newKey.replace(/\"\"/g, '"'));
}
}
else {
str = '{}';
}
str = str.replace(/\n/g,'');
return str.replace(/\"\"/g, '"');
return str;
},

isValidDocument: function(payload) {
@@ -52,7 +52,7 @@ Mongoman.DocumentsController = Ember.ArrayController.extend({
}
});

return text;
return text.replace(/\"\"\"/g, '"');
},


@@ -101,12 +101,12 @@ Mongoman.DocumentsController = Ember.ArrayController.extend({
buttons: {
"Add Document" : function() {

var valid = self.isValidDocument(self.newDocument);
var json = self.substituteFields(self.newDocument.trim());
var valid = self.isValidDocument(json);

if (valid && self.newDocument) {
if (valid && json) {

var url = '/documents/?';
var json = self.substituteFields(self.newDocument.trim());
json = json.split('\n').map(function(token) { return token.trim(); }).join('');

Mongoman.PostRequest.post(url ,

0 comments on commit 4a65b14

Please sign in to comment.